def get_translations(self):
if self.get_locale is None:
return None
locale = self.get_locale()
if locale is None:
return None
elif not isinstance(locale, str):
# locale might be an instance of babel.core.Locale
locale = str(locale)
if '_' in locale or '-' in locale:
# If the locale has territory (e.g. 'ko_KR')
# we can search the proper match (e.g. ko_KR) and then
# the non-territory match (e.g. ko) as a fallback.
locale = locale.replace('-', '_')
locales = [locale, locale[:locale.index('_')]]
else:
locales = [locale]
return gettext.translation(
'dodotable',
os.path.join(os.path.dirname(__file__), '..', 'locale'),
fallback=True,
codeset='utf-8',
languages=locales
)
评论列表
文章目录