The locale.getdefaultlocale is deprecated
This patch is prompted by the annoying deprecation warning: DeprecationWarning: Use setlocale(), getencoding() and getlocale() instead But getdefaultlocale() is scheduled to be removed in Python 3.13, so we need to act anyway. We use LC_CTYPE as the most compatible setting. Probablly what we really want for translations is LANG, but that is not a valid argument for getlocale(). Fortunately, LC_CTYPE is set when LANG is set, so this works for us. Change-Id: I07bdbaf95108aa4fdb4c645c12b196dcb820059b
This commit is contained in:
parent
03605c2db7
commit
721dd76cb9
|
@ -98,7 +98,7 @@ class Message(str):
|
|||
def _translate_msgid(msgid, domain, desired_locale=None,
|
||||
has_contextual_form=False, has_plural_form=False):
|
||||
if not desired_locale:
|
||||
system_locale = locale.getdefaultlocale()
|
||||
system_locale = locale.getlocale(locale.LC_CTYPE)
|
||||
# If the system locale is not available to the runtime use English
|
||||
if not system_locale or not system_locale[0]:
|
||||
desired_locale = 'en_US'
|
||||
|
|
Loading…
Reference in New Issue