util/TranslationCatalogs.py
branch1.1 Korean release
changeset 968 eee7625de1f7
parent 817 1a3cc2065216
child 1511 91538d0c242c
equal deleted inserted replaced
808:6e205c1f05a0 968:eee7625de1f7
       
     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_DEFAULT
       
    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)