laurent@815: #!/usr/bin/env python
laurent@815: # -*- coding: utf-8 -*-
laurent@815: 
laurent@815: import os 
laurent@815: 
laurent@815: import wx
laurent@815: 
laurent@815: # Get the default language
laurent@817: langid = wx.LANGUAGE_DEFAULT
laurent@815: 
laurent@815: # Define locale for wx
laurent@815: locale = wx.Locale(langid)
laurent@815: 
laurent@815: def GetDomain(path):
laurent@815:     for name in os.listdir(path):
laurent@815:         filepath = os.path.join(path, name)
laurent@815:         basename, fileext = os.path.splitext(name)
laurent@815:         if os.path.isdir(filepath):
laurent@815:             result = GetDomain(filepath)
laurent@815:             if result is not None:
laurent@815:                 return result
laurent@815:         elif fileext == ".mo":
laurent@815:             return basename
laurent@815:     return None
laurent@815: 
laurent@815: def AddCatalog(locale_dir):
laurent@815:     if os.path.exists(locale_dir) and os.path.isdir(locale_dir):
laurent@815:         domain = GetDomain(locale_dir)
laurent@815:         if domain is not None:
laurent@815:             locale.AddCatalogLookupPathPrefix(locale_dir)
laurent@815:             locale.AddCatalog(domain)