Return the localized translation of message, based on the language, and
    locale directory of the domain specified in the translation key (or the
    current global domain). This function is usually aliased as ``_``.
509089
def gettext(*args, **kwargs):
    
    key = args[0]
    key_match = TRANSLATION_KEY_RE.match(key)
    translation = _gettext(*args, **kwargs)
    if not key_match or translation != key:
        return translation

    return _get_domain(key_match).gettext(*args, **kwargs)
936490
function translate (key, locale) {
	if (locale) {
		let loc = i18n.getLocale();
		i18n.setLocale(locale);
		let res = i18n.__(key);
		i18n.setLocale(loc);
		return res;
	} else {
		return i18n.__(key);
	}
}
270091
public function getTranslator($domain = '')
    {
        if (empty($domain)) {
            $domain = $this->default_domain;
        }

        if (! isset($this->domains[$this->locale])) {
            $this->domains[$this->locale] = [];
        }

        if (! isset($this->domains[$this->locale][$domain])) {
            if (isset($this->paths[$domain])) {
                $base = $this->paths[$domain];
            } else {
                $base = './';
            }

            $locale_names = $this->listLocales($this->locale);

            $filename = '';
            foreach ($locale_names as $locale) {
                $filename = "$base/$locale/LC_MESSAGES/$domain.mo";
                if (file_exists($filename)) {
                    break;
                }
            }

            // We don't care about invalid path, we will get fallback
            // translator here
            $this->domains[$this->locale][$domain] = new Translator($filename);
        }

        return $this->domains[$this->locale][$domain];
    }
94260
def locale(self):
        
        if self.platform in ("linux", "darwin", "freebsd"):
            locale = self._exec_command('echo $LANG')
            if locale is not None:
                return locale.split(b'.')[-1].decode('ascii').lower()
        return None
332286
def translation_exists(self, slug, lang):
        """"""

        try:
            return translations.Translation.get(
                project_slug=self.get_project_slug(lang),
                slug=slug,
                lang=lang,
            )

        except (NotFoundError, RemoteServerError):
            pass

        return False
1265289
protected function get(string &$locale, string $domain, string $string): string
    {
        if ($this->catalogueManager->get($locale)->has($domain, $string)) {
            return $this->catalogueManager->get($locale)->get($domain, $string);
        }

        $locale = $this->config->getFallbackLocale();

        if ($this->catalogueManager->get($locale)->has($domain, $string)) {
            return $this->catalogueManager->get($locale)->get($domain, $string);
        }

        // we can automatically register message
        if ($this->config->isAutoRegisterMessages()) {
            $this->catalogueManager->get($locale)->set($domain, $string, $string);
            $this->catalogueManager->save($locale);
        }

        //Unable to find translation
        return $string;
    }
746435
def fill_translation_cache(instance):
    

    if hasattr(instance, '_translation_cache'):
        # do not refill the cache
        return
    instance._translation_cache = {}

    # unsafed instances cannot have translations
    if not instance.pk:
        return

    for language_code in get_language_code_list():
        # see if translation for language_code was in the query
        field_alias = get_translated_field_alias('code', language_code)
        if getattr(instance, field_alias, None) is not None:
            field_names = [f.attname for f in instance._meta.translation_model._meta.fields]

            # if so, create a translation object and put it in the cache
            field_data = {}
            for fname in field_names:
                field_data[fname] = getattr(instance,
                                            get_translated_field_alias(fname, language_code))

            translation = instance._meta.translation_model(**field_data)
            instance._translation_cache[language_code] = translation

    # In some situations an (existing in the DB) object is loaded
    # without using the normal QuerySet.  In such case fallback to
    # loading the translations using a separate query.

    # Unfortunately, this is indistinguishable from the situation when
    # an object does not have any translations.  Oh well, we'll have
    # to live with this for the time being.
    if len(instance._translation_cache.keys()) == 0:
        for translation in instance.translations.all():
            instance._translation_cache[translation.language_code] = translation
1287745
public String localize(PrefixKind pk, String key, Object... args) {
        if (useRawMessages)
            return pk.key(key);
        else
            return messages.getLocalizedString(pk.key(key), args);
    }
1028515
def get_path(language):
  '''  '''
  filename = language.lower() + '.json'
  lang_file_path = os.path.join(_DEFAULT_DIR, filename)
  if not os.path.exists(lang_file_path):
    raise IOError('Could not find {} language file'.format(language))
  return lang_file_path
1022439
def get_language_pack(locale):
    
    pack = ALL_LANGUAGE_PACKS.get(locale)
    if not pack:
        filename = DIR + '/{}/LC_MESSAGES/messages.json'.format(locale)
        try:
            with open(filename) as f:
                pack = json.load(f)
                ALL_LANGUAGE_PACKS[locale] = pack
        except Exception:
            # Assuming english, client side falls back on english
            pass
    return pack
672335
def get_translation(self, uid):
        '''
            
        '''
        result = self.api_call('translation/{}/'.format(uid))
        if result.status_code == 200:
            translation = Translation(**json.loads(result.content))
        else:
            log.critical(
                'Error status when fetching translation from server: {'
                '}!'.format(
                    result.status_code))
            raise ValueError(result.content)
        return translation
6691
def get_locale(self):
        
        if not self.locale:
            try:
                import flask_babel as babel
                self.locale = str(babel.get_locale()).lower()
            except ImportError:
                from flask import current_app
                self.locale = current_app.config['DEFAULT_LOCALE'].lower

        return self.locale
1046201
@Route(method = HttpMethod.GET, uri = "i18n/{key}")
    public Result getMessage(@Parameter("key") String key, @QueryParameter("locale") Locale locale) {
        String message;
        if (locale != null && !locale.equals(InternationalizationService.DEFAULT_LOCALE)) {
            message = service.get(locale, key);
        } else {
            message = service.get(context().request().languages(), key);
        }

        if (message != null) {
            return ok(message).as(MimeTypes.TEXT);
        } else {
            return notFound("No message for " + key).as(MimeTypes.TEXT);
        }
    }
297314
def get(self, key: Text, locale: Optional[Text]) -> List[Tuple[Text, ...]]:
        

        locale = self.choose_locale(locale)

        return self.dict[locale][key]
1151781
public static String getLocalisedText(final Locale locale, final String text) {
		String message = null;
		String resourceBundleBaseName = getResourceBundleBaseName();

		if (!Util.empty(resourceBundleBaseName)) {
			Locale effectiveLocale = locale;

			if (effectiveLocale == null) {
				effectiveLocale = getEffectiveLocale();
			}

			try {
				// TODO: This is slow
				ResourceBundle bundle = ResourceBundle.getBundle(resourceBundleBaseName, effectiveLocale);
				message = bundle.getString(text);
			} catch (MissingResourceException e) {
				// Fall back to the Configuration mechanism for the default internal messages
				if (text != null && text.startsWith(ConfigurationProperties.INTERNAL_MESSAGE_PREFIX)) {
					message = ConfigurationProperties.getInternalMessage(text);
				}

				if (message == null && !MISSING_RESOURCES.contains(locale)) {
					LOG.error("Missing resource mapping for locale: " + locale + ", text: " + text);
					MISSING_RESOURCES.add(locale);
				}
			}
		} else if (text != null && text.startsWith(ConfigurationProperties.INTERNAL_MESSAGE_PREFIX)) {
			// Fall back to the Configuration mechanism for the default internal messages
			message = ConfigurationProperties.getInternalMessage(text);
		}

		return message;
	}
807374
private function getTranslationsForDomain($locale, $domain)
    {
        $allMessages = $this->getTranslationsForLocale($locale);

        if (!array_key_exists($domain, $allMessages)) {
            throw new \Exception('Domain ' . $domain . ' not found in the translations for locale ' . $locale);
        }

        return $allMessages[$domain];
    }
1026576
async def get_locale(self) -> Text:
        

        if self._locale_override:
            return self._locale_override
        else:
            return await self.user.get_locale()