def parse_translations(translations_path):
translations = {}
if os.path.isdir(translations_path):
for content in os.listdir(translations_path):
if not os.path.isdir(os.path.join(translations_path, content)):
lang, ext = os.path.splitext(content)
if ext == (os.extsep + 'mo') and RE_TRANSLATIONS.match(lang):
with open(os.path.join(translations_path, content),
mode="rb") as f:
translations[lang] = gettext.GNUTranslations(f)
if not translations:
# Untranslated module, assume hardcoded en-US strings
translations['en-US'] = gettext.NullTranslations()
return translations
评论列表
文章目录