X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=m_librarian%2Ftranslations.py;h=8542ffbe97b20d7562226d1370a430a105c0c206;hb=b18919cd708ccbea99334f8b949e77b1c4dfd2dc;hp=a979472c454e94df377ccaf4e7c85a5c74bb22ac;hpb=46ff77c09f3af957a4fce444d96bf942ddf342e7;p=m_librarian.git diff --git a/m_librarian/translations.py b/m_librarian/translations.py index a979472..8542ffb 100644 --- a/m_librarian/translations.py +++ b/m_librarian/translations.py @@ -3,17 +3,25 @@ import gettext import locale import os -language = locale.getdefaultlocale()[0] -translations = None -if language: +def get_translations(language): mo_filename = os.path.join( - os.path.dirname(__file__), 'translations', language + '.mo') + os.path.dirname(__file__), 'translations_dir', language + '.mo') if os.path.exists(mo_filename): mo_file = open(mo_filename, 'rb') translations = gettext.GNUTranslations(mo_file) mo_file.close() + return translations + return None + + +language = locale.getdefaultlocale()[0] +translations = None + +if language: + if language in ('ru_RU', 'Russian_Russia'): + language = 'ru' + translations = get_translations(language) if translations is None: translations = gettext.NullTranslations() -translation.install(unicode=True)