util/TranslationCatalogs.py
changeset 815 e4f24593a758
child 817 1a3cc2065216
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/util/TranslationCatalogs.py	Fri Sep 07 18:28:45 2012 +0200
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import os 
+
+import wx
+
+# Get the default language
+langid = wx.LANGUAGE_FRENCH
+
+# Define locale for wx
+locale = wx.Locale(langid)
+
+def GetDomain(path):
+    for name in os.listdir(path):
+        filepath = os.path.join(path, name)
+        basename, fileext = os.path.splitext(name)
+        if os.path.isdir(filepath):
+            result = GetDomain(filepath)
+            if result is not None:
+                return result
+        elif fileext == ".mo":
+            return basename
+    return None
+
+def AddCatalog(locale_dir):
+    if os.path.exists(locale_dir) and os.path.isdir(locale_dir):
+        domain = GetDomain(locale_dir)
+        if domain is not None:
+            locale.AddCatalogLookupPathPrefix(locale_dir)
+            locale.AddCatalog(domain)