]> git.phdru.name Git - m_librarian.git/blob - m_librarian/translations.py
ba5f44c7f6c7719a2839c7182976b7b9e0de9a0d
[m_librarian.git] / m_librarian / translations.py
1
2 import gettext
3 import locale
4 import os
5
6 language = locale.getdefaultlocale()[0]
7 translations = None
8
9 if language:
10     mo_filename = os.path.join(
11         os.path.dirname(__file__), 'translations', language + '.mo')
12     if os.path.exists(mo_filename):
13         mo_file = open(mo_filename, 'rb')
14         translations = gettext.GNUTranslations(mo_file)
15         mo_file.close()
16
17 if translations is None:
18     translations = gettext.NullTranslations()