def load_translations(locale):
  """Load the translation for a locale.  If a locale does not exist
  the return value a fake translation object.
  """
  from werkzeug.utils import import_string

  from kay.i18n.translations import KayTranslations
  domain = "messages"
  ret = KayTranslations.load(utils.get_kay_locale_path(), locale, domain)
  def _merge(path):
    t = KayTranslations.load(path, locale, domain)
    if t is not None:
      if ret is None:
        return t
      elif isinstance(ret, KayTranslations):
        ret.merge(t)
    return ret
  try:
    installed_apps = local.app.app_settings.INSTALLED_APPS
  except AttributeError:
    installed_apps = settings.INSTALLED_APPS
  for appname in installed_apps:
    app = import_string(appname)
    apppath = os.path.join(os.path.dirname(app.__file__), 'i18n')

    if os.path.isdir(apppath):
      ret = _merge(apppath)
  # Add I18N_DIR
  try:
    target = os.path.join(kay.PROJECT_DIR, local.app.app_settings.I18N_DIR)
    if os.path.isdir(target):
      ret = _merge(target)
  except __HOLE__:
    pass
  return ret
dataset/ETHPy150Open IanLewis/kay/kay/i18n/__init__.py/load_translations