util/TranslationCatalogs.py
changeset 815 e4f24593a758
child 817 1a3cc2065216
equal deleted inserted replaced
814:5743cbdff669 815:e4f24593a758
       
     1 #!/usr/bin/env python
       
     2 # -*- coding: utf-8 -*-
       
     3 
       
     4 import os 
       
     5 
       
     6 import wx
       
     7 
       
     8 # Get the default language
       
     9 langid = wx.LANGUAGE_FRENCH
       
    10 
       
    11 # Define locale for wx
       
    12 locale = wx.Locale(langid)
       
    13 
       
    14 def GetDomain(path):
       
    15     for name in os.listdir(path):
       
    16         filepath = os.path.join(path, name)
       
    17         basename, fileext = os.path.splitext(name)
       
    18         if os.path.isdir(filepath):
       
    19             result = GetDomain(filepath)
       
    20             if result is not None:
       
    21                 return result
       
    22         elif fileext == ".mo":
       
    23             return basename
       
    24     return None
       
    25 
       
    26 def AddCatalog(locale_dir):
       
    27     if os.path.exists(locale_dir) and os.path.isdir(locale_dir):
       
    28         domain = GetDomain(locale_dir)
       
    29         if domain is not None:
       
    30             locale.AddCatalogLookupPathPrefix(locale_dir)
       
    31             locale.AddCatalog(domain)