X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=m_librarian%2Ftranslations.py;h=e3cbce455d5b6a739c50d0a6b35711e0a8a505d1;hb=62a23d8be94f167c8bb2bb936d5445e8995b30bd;hp=a979472c454e94df377ccaf4e7c85a5c74bb22ac;hpb=46ff77c09f3af957a4fce444d96bf942ddf342e7;p=m_librarian.git diff --git a/m_librarian/translations.py b/m_librarian/translations.py index a979472..e3cbce4 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') 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)