Get translation for a specific locale.
975331
def _get_translation_for_locale(self, locale):
        """"""
        translations = None

        for dirname in self.paths:
            # Load a single catalog.
            catalog = Translations.load(dirname, [locale], domain=self.domain)
            if translations is None:
                if isinstance(catalog, Translations):
                    translations = catalog
                continue

            try:
                # Merge catalog into global catalog
                translations.merge(catalog)
            except AttributeError:
                # Translations is probably NullTranslations
                if isinstance(catalog, NullTranslations):
                    current_app.logger.debug(
                        'Compiled translations seems to be missing'
                        ' in {0}.'.format(dirname))
                    continue
                raise

        return translations or NullTranslations()
981643
def get_translator (domain, directory, languages=None,
                    translatorklass=Translator, fallback=False,
                    fallbackklass=NullTranslator):
    """"""
    translator = gettext.translation(domain, localedir=directory,
            languages=languages, class_=translatorklass, fallback=fallback)
    if not isinstance(translator, gettext.GNUTranslations) and fallbackklass:
        translator = fallbackklass()
    return translator
1160906
public static Locale getLocale(
    Object      value)
  {
    if (value == null)
    {
        return null;
    }

    if (value instanceof Locale)
    {
        return ((Locale) value);
    }

    return getLocaleInternal(value.toString());
  }
474510
public Translation getWithFallBack(Locale locale) {
        Translation tr = get(locale.toString());
        if (tr == null) {
            tr = get(locale.getLanguage());
            if (tr == null)
                tr = get("en");
        }
        return tr;
    }
383029
def fetch_attribute(locale, name)
      translation = record.translation_for(locale)
      return translation && translation.send(name)
    end
319901
public Translation get(String locale) {
        locale = locale.replace("-", "_");
        Translation tr = translations.get(locale);
        if (locale.contains("_") && tr == null)
            tr = translations.get(locale.substring(0, 2));

        return tr;
    }
1170966
def get_localized_docstring(obj, domain):
    """"""
    if obj.__class__.__doc__ is not None:
        return inspect.cleandoc(
            gettext.dgettext(domain, obj.__class__.__doc__))
940024
protected function getTranslation($key, $locale) {
        if( isset($this->translations[$locale][$key]) )
            return $this->translations[$locale][$key];

        return $key;
    }
985653
function getLocale(lang) {
  lang = lang.toLowerCase();
  if (!locales.hasOwnProperty(lang)) {
    locales[lang] = {};
    try {
      locales[lang] = require('../locale/' + lang);
    } catch (err) {
      if (lang !== 'en') {
        return getLocale('en');
      }
      // This is not reachable, unless someone deletes ../locale/en.json
      throw err;
    }
  }

  return locales[lang];
}
69041
def get_translation(modname, dirname=None):
    """"""
    if dirname is None:
        dirname = modname

    def translate_dumb(x):
        """Dumb function to not use translations."""
        if not is_unicode(x):
            return to_text_string(x, "utf-8")
        return x

    locale_path = get_module_data_path(dirname, relpath="locale",
                                       attr_name='LOCALEPATH')

    # If LANG is defined in Ubuntu, a warning message is displayed,
    # so in Unix systems we define the LANGUAGE variable.
    language = load_lang_conf()
    if os.name == 'nt':
        # Trying to set LANG on Windows can fail when Spyder is
        # run with admin privileges.
        # Fixes issue 6886
        try:
            os.environ["LANG"] = language      # Works on Windows
        except Exception:
            return translate_dumb
    else:
        os.environ["LANGUAGE"] = language  # Works on Linux
 
    import gettext
    try:
        _trans = gettext.translation(modname, locale_path, codeset="utf-8")
        lgettext = _trans.lgettext
        def translate_gettext(x):
            if not PY3 and is_unicode(x):
                x = x.encode("utf-8")
            y = lgettext(x)
            if is_text_string(y) and PY3:
                return y
            else:
                return to_text_string(y, "utf-8")
        return translate_gettext
    except Exception:
        return translate_dumb
805641
def desk_locale(self, locale):
        """"""

        locale = locale.lower().replace('-', '_')
        return self.vendor_locale_map.get(locale, locale)
288510
def locale(self, value):
        """"""
        if not isinstance(value, Locale):
            value = Locale.parse(value)
        self.local.babel_locale = value
245268
public static Locale getLocaleFromString(String locale) throws LocaleException {
		for(Locale l : Locale.getAvailableLocales()) {
			if(locale.toLowerCase().equals(l.toString().toLowerCase())) {
				return l;
			}
		}
		throw new LocaleException();
	}
1221166
def get_browser_locale(self, default: str = "en_US") -> tornado.locale.Locale:
        
        if "Accept-Language" in self.request.headers:
            languages = self.request.headers["Accept-Language"].split(",")
            locales = []
            for language in languages:
                parts = language.strip().split(";")
                if len(parts) > 1 and parts[1].startswith("q="):
                    try:
                        score = float(parts[1][2:])
                    except (ValueError, TypeError):
                        score = 0.0
                else:
                    score = 1.0
                locales.append((parts[0], score))
            if locales:
                locales.sort(key=lambda pair: pair[1], reverse=True)
                codes = [l[0] for l in locales]
                return locale.get(*codes)
        return locale.get(default)
804715
function getText(locale, ...args) {
    const key = args[0];
    if (!key) return null;

    // try locale
    let resource = ebLocales[locale] || {};
    let text = resource[key];
    if (text === undefined && locale !== 'en-us') {
      // try en-us
      resource = ebLocales['en-us'] || {};
      text = resource[key];
    }
    // equal key
    if (text === undefined) {
      text = key;
    }
    // format
    args[0] = text;
    return localeutil.getText.apply(localeutil, args);
  }
243273
def avail(locale):
    '''
    
    '''
    try:
        normalized_locale = salt.utils.locales.normalize_locale(locale)
    except IndexError:
        log.error('Unable to validate locale "%s"', locale)
        return False
    avail_locales = __salt__['locale.list_avail']()
    locale_exists = next((True for x in avail_locales
                          if salt.utils.locales.normalize_locale(x.strip()) == normalized_locale), False)
    return locale_exists
672244
def get_translations(self, status=None):
        '''
            
        '''
        if status is not None:
            result = self.api_call('translation/?status=%s' % status)
        else:
            result = self.api_call('translation/')
        if result.status_code == 200:
            translations_json = json.loads(result.content)["objects"]
            translations = [Translation(**tj) for tj in translations_json]
        else:
            log.critical(
                'Error status when fetching translation from server: {'
                '}!'.format(
                    result.status_code))
            translations = []
        return translations