X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=m_librarian%2Ftranslations.py;h=e3cbce455d5b6a739c50d0a6b35711e0a8a505d1;hb=f4db6643ccf1628715a0724a3cede14439d1e514;hp=ba5f44c7f6c7719a2839c7182976b7b9e0de9a0d;hpb=e67b775c7267825b9f2d353793dc4cd25b5fdec1;p=m_librarian.git diff --git a/m_librarian/translations.py b/m_librarian/translations.py index ba5f44c..e3cbce4 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') 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()