X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=m_librarian%2Ftranslations.py;h=8542ffbe97b20d7562226d1370a430a105c0c206;hb=f02f8a6f7fd47bb6ab22966d783a017d821c4609;hp=ba5f44c7f6c7719a2839c7182976b7b9e0de9a0d;hpb=e67b775c7267825b9f2d353793dc4cd25b5fdec1;p=m_librarian.git diff --git a/m_librarian/translations.py b/m_librarian/translations.py index ba5f44c..8542ffb 100644 --- a/m_librarian/translations.py +++ b/m_librarian/translations.py @@ -3,16 +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()