]> git.phdru.name Git - m_librarian.git/blobdiff - m_librarian/translations.py
Use gettext
[m_librarian.git] / m_librarian / translations.py
diff --git a/m_librarian/translations.py b/m_librarian/translations.py
new file mode 100644 (file)
index 0000000..e2234b9
--- /dev/null
@@ -0,0 +1,15 @@
+
+import gettext
+import locale
+import os
+
+language = locale.getdefaultlocale()[0]
+mo_filename = os.path.join(
+    os.path.dirname(__file__), 'translations', language + '.mo')
+if os.path.exists(mo_filename):
+    mo_file = open(mo_filename, 'rb')
+    translation = gettext.GNUTranslations(mo_file)
+    mo_file.close()
+else:
+    translation = gettext.NullTranslations()
+translation.install(unicode=True)