Translates message/text and returns it in a unicode string.
        Using runtime to get i18n service.
350675
def ugettext(self, text):
        
        runtime_service = self.runtime.service(self, "i18n")
        runtime_ugettext = runtime_service.ugettext
        return runtime_ugettext(text)
276789
function i18n() {
				const i18nElement = findChild(libraryAppData, "i18n");
				if ( i18nElement ) {
					const i18n = i18nElement._;
					if ( i18n === "false" ) {
						return false;
					} else if ( i18n === "true" ) {
						return "messagebundle.properties";
					} else {
						return i18n;
					}
					// log.verbose("  sap.ui5/library/i18n property taken from .library appData: '%s'", library.i18n);
				} else {
					if ( libBundle.findResource("messagebundle.properties") != null ) {
						// log.verbose("  sap.ui5/library/i18n property determined from resources: '%s'", library.i18n);
						return "messagebundle.properties";
					} else {
						return false;
					}
				}
			}
589061
def _get_translation(self, lang):
        """"""

        try:
            return self._translations[lang]
        except KeyError:
            # The fact that `fallback=True` is not the default is a serious design flaw.
            rv = self._translations[lang] = gettext.translation(self._domain, localedir=localedir, languages=[lang],
                                                                fallback=True)
            return rv
930015
function (msgctxt, msgid) {
  var message;
  if (this.$i18n.getLocaleMessage(this.$i18n.activeLocale)[msgctxt]) {
    message = this.$i18n.getLocaleMessage(this.$i18n.activeLocale)[msgctxt][msgid];
  }

  if (!message) {
    return msgid
  } else {
    return message.msgstr[0] || message.msgid
  }
}
994113
def t(i18n_msg):
    
    text = to_unicode(i18n_msg)
    try:
        request = api.get_request()
        domain = getattr(i18n_msg, "domain", "senaite.core")
        text = translate(text, domain=domain, context=request)
    except UnicodeDecodeError:
        # TODO: This is only a quick fix
        logger.warn("{} couldn't be translated".format(text))
    return to_utf8(text)
598135
def to_unicode(text):
    
    if not isinstance(text, str):
        tmpl = 'expected unicode string, got %s value %s'
        raise TypeError(tmpl % (type(text), text))
    return text
75707
public final String getTranslatedName(ResourceBundle messages) {
    try {
      return messages.getString(getShortCodeWithCountryAndVariant());
    } catch (MissingResourceException e) {
      try {
        return messages.getString(getShortCode());
      } catch (MissingResourceException e1) {
        return getName();
      }
    }
  }
826731
public String getMessage(String key, Locale locale)
	{
		if (null == locale)
		{
			return getMessage(key);
		}
		return CollectionTools.getString(getResourceBundle(locale), key, getBehaviourOnMissingMessage().getValueOnMissingMessage(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;
	}
641005
def to_unicode(text):
    """"""
    if isinstance(text, unicode):
        return text
    if isinstance(text, six.string_types):
        return decode_to_unicode(text)
    return unicode(text)
120186
function ungettext(msgid1, msgid2, n) {
        if (_i18n_locale.locale_name == 'en_DEBUG') return __debug_trans_str(msgid1);
        var id = ''+_i18n_plural(n)+'-'+msgid1;
        var entry = _i18n_catalog[id];
        return entry == undefined ? (n==1 ? msgid1 : msgid2)  : entry;
    }
614974
private String getMessage(boolean localized) {
        String msg = localized ? super.getLocalizedMessage() : super.getMessage();
        StringBuilder sb = new StringBuilder(msg == null ? "" : msg);
        
        for (Throwable exception : exceptions) {
            msg = localized ? exception.getLocalizedMessage() : exception.getMessage();
            
            if (msg != null) {
                sb.append(sb.length() == 0 ? "" : "\n\n").append(msg);
            }
        }
        
        return sb.toString();
    }
376413
protected String getI18n(final String aMessageKey, final int aIntDetail) {
        return StringUtils.normalizeWS(myBundle.get(aMessageKey, Integer.toString(aIntDetail)));
    }
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;
    }
1147387
def translation(language):
    
    global _translations
    if language not in _translations:
        _translations[language] = Translations(language)
    return _translations[language]
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
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)