def translation(language):
 global _translations
 t = _translations.get(language, None)
 if (t is not None):
  return t
 from django.conf import settings
 globalpath = os.path.join(os.path.dirname(upath(sys.modules[settings.__module__].__file__)), u'locale')
 def _fetch(lang, fallback=None):
  global _translations
  res = _translations.get(lang, None)
  if (res is not None):
   return res
  loc = to_locale(lang)
  def _translation(path):
   try:
    t = gettext_module.translation(u'django', path, [loc], DjangoTranslation)
    t.set_language(lang)
    return t
   except IOError:
    return None
  res = _translation(globalpath)
  base_lang = (lambda x: x.split(u'-', 1)[0])
  if (base_lang(lang) in [base_lang(trans) for trans in _translations]):
   res._info = res._info.copy()
   res._catalog = res._catalog.copy()
  def _merge(path):
   t = _translation(path)
   if (t is not None):
    if (res is None):
     return t
    else:
     res.merge(t)
   return res
  for appname in reversed(settings.INSTALLED_APPS):
   app = import_module(appname)
   apppath = os.path.join(os.path.dirname(upath(app.__file__)), u'locale')
   if os.path.isdir(apppath):
    res = _merge(apppath)
  for localepath in reversed(settings.LOCALE_PATHS):
   if os.path.isdir(localepath):
    res = _merge(localepath)
  if (res is None):
   if (fallback is not None):
    res = fallback
   else:
    return gettext_module.NullTranslations()
  _translations[lang] = res
  return res
 default_translation = _fetch(settings.LANGUAGE_CODE)
 current_translation = _fetch(language, fallback=default_translation)
 return current_translation

def translation ( language ) : global _translations t = _translations . get ( language , None ) if ( t is not None ) : return t from django . conf import settings globalpath = os . path . join ( os . path . dirname ( upath ( sys . modules [ settings . __module__ ] . __file__ ) ) , u'locale' ) def _fetch ( lang , fallback = None ) : global _translations res = _translations . get ( lang , None ) if ( res is not None ) : return res loc = to_locale ( lang ) def _translation ( path ) : try : t = gettext_module . translation ( u'django' , path , [ loc ] , DjangoTranslation ) t . set_language ( lang ) return t except IOError : return None res = _translation ( globalpath ) base_lang = ( lambda x : x . split ( u'-' , 1 ) [ 0 ] ) if ( base_lang ( lang ) in [ base_lang ( trans ) for trans in _translations ] ) : res . _info = res . _info . copy ( ) res . _catalog = res . _catalog . copy ( ) def _merge ( path ) : t = _translation ( path ) if ( t is not None ) : if ( res is None ) : return t else : res . merge ( t ) return res for appname in reversed ( settings . INSTALLED_APPS ) : app = import_module ( appname ) apppath = os . path . join ( os . path . dirname ( upath ( app . __file__ ) ) , u'locale' ) if os . path . isdir ( apppath ) : res = _merge ( apppath ) for localepath in reversed ( settings . LOCALE_PATHS ) : if os . path . isdir ( localepath ) : res = _merge ( localepath ) if ( res is None ) : if ( fallback is not None ) : res = fallback else : return gettext_module . NullTranslations ( ) _translations [ lang ] = res return res default_translation = _fetch ( settings . LANGUAGE_CODE ) current_translation = _fetch ( language , fallback = default_translation ) return current_translation
create an array with a translation matrix .