You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The method "_locales_to_names()" from the "Translations" class (babel/support.py) does not correctly convert a given Locale to a List of language names.
Instead of calling str() on the parameter variable locales (note the -s), it is called on the module object locale (without -s) if the parameter variable locales is an instance of Locale (see code below) .
def_locales_to_names(
locales: Iterable[str|Locale] |str|Locale|None,
) ->list[str] |None:
"""Normalize a `locales` argument to a list of locale names. :param locales: the list of locales in order of preference (items in this list can be either `Locale` objects or locale strings) """iflocalesisNone:
returnNoneifisinstance(locales, Locale):
return [str(locale)]
ifisinstance(locales, str):
return [locales]
return [str(locale) forlocaleinlocales]
The 4th lowest line should read return [str(locales)] instead of return [str(locale)] (as in locale the module object).
As a result, the gettext.find() call in the load method of the Translations class does not return a valid .mo file path and therefore the translations cannot be loaded.
The text was updated successfully, but these errors were encountered:
Description
The method "_locales_to_names()" from the "Translations" class (babel/support.py) does not correctly convert a given Locale to a List of language names.
Instead of calling
str()
on the parameter variablelocales
(note the -s), it is called on the module objectlocale
(without -s) if the parameter variablelocales
is an instance ofLocale
(see code below) .The 4th lowest line should read
return [str(locales)]
instead ofreturn [str(locale)]
(as inlocale
the module object).As a result, the
gettext.find()
call in theload
method of theTranslations
class does not return a valid .mo file path and therefore the translations cannot be loaded.The text was updated successfully, but these errors were encountered: