def load_gettext_translations(directory, domain):
 import gettext
 global _translations
 global _supported_locales
 global _use_gettext
 _translations = {}
 for lang in os.listdir(directory):
  if lang.startswith('.'):
   continue
  if os.path.isfile(os.path.join(directory, lang)):
   continue
  try:
   os.stat(os.path.join(directory, lang, 'LC_MESSAGES', (domain + '.mo')))
   _translations[lang] = gettext.translation(domain, directory, languages=[lang])
  except Exception as e:
   gen_log.error("Cannot load translation for '%s': %s", lang, str(e))
   continue
 _supported_locales = frozenset((list(_translations.keys()) + [_default_locale]))
 _use_gettext = True
 gen_log.debug('Supported locales: %s', sorted(_supported_locales))

def load_gettext_translations ( directory , domain ) : import gettext global _translations global _supported_locales global _use_gettext _translations = { } for lang in os . listdir ( directory ) : if lang . startswith ( '.' ) : continue if os . path . isfile ( os . path . join ( directory , lang ) ) : continue try : os . stat ( os . path . join ( directory , lang , 'LC_MESSAGES' , ( domain + '.mo' ) ) ) _translations [ lang ] = gettext . translation ( domain , directory , languages = [ lang ] ) except Exception as e : gen_log . error ( "Cannot load translation for '%s': %s" , lang , str ( e ) ) continue _supported_locales = frozenset ( ( list ( _translations . keys ( ) ) + [ _default_locale ] ) ) _use_gettext = True gen_log . debug ( 'Supported locales: %s' , sorted ( _supported_locales ) )
loads translations from gettexts locale tree locale tree is similar to systems /usr/share/locale .