Translate a text string based on our i18n files.
@since 3.1
6428
public static String i18n(ResourceBundle messages, String key, Object... messageArguments) {
    MessageFormat formatter = new MessageFormat("");
    formatter.applyPattern(messages.getString(key).replaceAll("'", "''"));
    return formatter.format(messageArguments);
  }
165937
function i18n($file, $locale = NULL){
        $this->fileName= $file;
        $this->i18nContent= NULL;
        if($locale != NULL){
            if(file_exists(PATHAPP . 'src/content/' . $file . "_$locale" . '.txt')){
                $this->i18nContent= \E_fn\load_application_file('src/content/' . $file . "_$locale" . '.txt');
                $this->i18nContent= \E_fn\parse_properties($this->i18nContent);
                $this->locale= $locale;
            }
        }
        if($this->i18nContent == NULL){
            $this->i18nContent= \E_fn\load_application_file('src/content/' . $file . '.txt');
            $this->i18nContent= \E_fn\parse_properties($this->i18nContent);
            $this->locale= 'Default';
        }
    }
202676
protected function searchDefaultTranslate()
    {
        // call in: loadInternalData()
        if ($this->searchContent) {
            $this->listAllDefaultTranslate = $this->searchContent->getList();

            if ($this->dictionary && $this->listAllDefaultTranslate) {
                // if define dictionary
                foreach ($this->listAllDefaultTranslate as $identification => $item) {
                    if ($item['type'] == 'translation') {
                        $message = $item['value'];
                        // save only not exist identification and only string message or identification is same like dictionary index (default translate)
//                        if ((!isset($this->dictionary[$identification]) && !is_array($message)) || $this->dictionary[$identification] == $identification) {
                        if (!isset($this->dictionary[$identification]) || $this->dictionary[$identification] == $identification) {
                            // call only save default value load from files
                            $this->saveTranslate($identification, $message);
                        }
                    }
                }
            }
        }
    }
1117137
private function addTranslatable($text)
    {
        if (strlen($text) > 1 && !isset($this->translatables[$text])) {
            $this->translatables[$text] = '';
        }
    }
1069131
function t(path, bindings) {
        let string, isTheme, msg;

        currentLocale = I18n.locale();
        if (bindings !== undefined) {
            isTheme = bindings.isThemeString;
            delete bindings.isThemeString;
        }
        string = I18n.findString(path, {isThemeString: isTheme});

        // If the path returns an array (as in the case with anything that has multiple paragraphs such as emails), then
        // loop through them and return an array of translated/formatted strings. Otherwise, just return the normal
        // translated/formatted string.
        if (Array.isArray(string)) {
            msg = [];
            string.forEach(function (s) {
                let m = new MessageFormat(s, currentLocale);

                try {
                    m.format(bindings);
                } catch (err) {
                    logging.error(err.message);

                    // fallback
                    m = new MessageFormat(coreStrings.errors.errors.anErrorOccurred, currentLocale);
                    m = msg.format();
                }

                msg.push(m);
            });
        } else {
            msg = new MessageFormat(string, currentLocale);

            try {
                msg = msg.format(bindings);
            } catch (err) {
                logging.error(err.message);

                // fallback
                msg = new MessageFormat(coreStrings.errors.errors.anErrorOccurred, currentLocale);
                msg = msg.format();
            }
        }

        return msg;
    }
841494
private function translate($text, $localeCode)
    {
        $this->translator->setLocale($localeCode);

        return $this->translator->trans($text);
    }
1151584
public function translate($text, array $params = [], $source = 'app')
    {
        $messages = $this->load($source);
        $message = vsprintf(isset($messages[$text]) ? $messages[$text] : $text, $params);

        return $message ? $message : $text;
    }
2104
private function saveStringToLocales()
    {
        $gettextEntries = $this->extractGettextStrings();

        $root = Strata::getRootPath();

        foreach ($gettextEntries as $translation) {
            $references = $translation->getReferences();
            $translation->deleteReferences();

            foreach ($references as $idx => $context) {
                $translation->addReference(str_replace($root, "~", $context[0]), $context[1]);
            }
        }

        foreach ($this->getLocales() as $locale) {
            $this->addGettextEntriesToLocale($locale, $gettextEntries);
        }
    }
1151567
def translate(patterns, *, flags=0):
    """"""

    flags = _flag_transform(flags)
    return _wcparse.translate(_wcparse.split(patterns, flags), flags)
587603
function(text){

    	var options, language, path;

			language = hashedit.language;

      // translatable
      if(hashedit.canTranslate === true) {

    		// make sure library is installed
        if(i18n !== undefined) {

          if(hashedit.isI18nInit === false) {

            // get language path
            path = hashedit.languagePath;
            path = hashedit.replaceAll(path, '{{language}}', hashedit.language);

      			// set language
      			options = {
      		        lng: hashedit.language,
      		        getAsync : false,
      		        useCookie: false,
      		        useLocalStorage: false,
      		        fallbackLng: 'en',
      		        resGetPath: path,
      		        defaultLoadingValue: ''
      		    };

            // init
      			i18n.init(options);

      			// set flag
      			hashedit.isI18nInit = true;
    			}
    		}

  		}

  		return i18n.t(text);
  	}
152987
function _extractTranslation(regexName, regex, content, file, lineNumber, results) {
      var r;
      _log.debug("---------------------------------------------------------------------------------------------------");
      _log.debug('Process extraction with regex : "' + regexName + '"');
      _log.debug(regex);
      regex.lastIndex = 0;
      while ((r = regex.exec(content)) !== null) {

        // Result expected [STRING, KEY, SOME_REGEX_STUF]
        // Except for plural hack [STRING, KEY, ARRAY_IN_STRING]
        if (r.length >= 2) {
          var translationKey, evalString;
          var translationDefaultValue = "";

          switch (regexName) {
            case 'HtmlDirectivePluralFirst':
              var tmp = r[1];
              r[1] = r[2];
              r[2] = tmp;
              /* falls through */
            case 'HtmlDirectivePluralLast':
              evalString = eval(r[2]);
              if (_.isArray(evalString) && evalString.length >= 2) {
                translationDefaultValue = "{NB, plural, one{" + evalString[0] + "} other{" + evalString[1] + "}" + (evalString[2] ? ' ' + evalString[2] : '');
              }
              translationKey = r[1].trim();
              break;
            default:
              translationKey = r[1].trim();
          }

          // Avoid empty translation
          if (translationKey === "") {
            return;
          }

          switch (regexName) {
            case "commentSimpleQuote":
            case "HtmlFilterSimpleQuote":
            case "JavascriptServiceSimpleQuote":
            case "JavascriptServiceInstantSimpleQuote":
            case "JavascriptFilterSimpleQuote":
            case "HtmlNgBindHtml":
              translationKey = translationKey.replace(/\\\'/g, "'");
              break;
            case "commentDoubleQuote":
            case "HtmlFilterDoubleQuote":
            case "JavascriptServiceDoubleQuote":
            case "JavascriptServiceInstantDoubleQuote":
            case "JavascriptFilterDoubleQuote":
              translationKey = translationKey.replace(/\\\"/g, '"');
              break;
            case "JavascriptServiceArraySimpleQuote":
            case "JavascriptServiceArrayDoubleQuote":
              var key;

              if(regexName === "JavascriptServiceArraySimpleQuote") {
                key = translationKey.replace(/'/g, '');
              } else {
                key = translationKey.replace(/"/g, '');
              }
              key = key.replace(/[\][]/g, '');
              key = key.split(',');

              key.forEach(function(item){
                item = item.replace(/\\\"/g, '"').trim();
                if (results[item]) {
                  results[item].sourceFiles.push({
                    file: file,
                    line: lineNumber
                  });
                } else {
                  results[item] = {
                    defaultValue: translationDefaultValue,
                    sourceFiles: [{
                      file: file,
                      line: lineNumber
                    }]
                  };
                }
              });
              break;
          }

          if( regexName !== "JavascriptServiceArraySimpleQuote" &&
              regexName !== "JavascriptServiceArrayDoubleQuote") {
            if (results[translationKey]) {
              results[translationKey].sourceFiles.push({
                file: file,
                line: lineNumber
              });
            } else {
              results[ translationKey ] = {
                defaultValue: translationDefaultValue,
                sourceFiles: [{
                  file: file,
                  line: lineNumber
                }]
              };
            }
          }
        }
      }
    }
229106
function translate(content, langFile) {
  return content.replace(templateRegEx, function (match, capture) {
    return (0, _lodash2.default)(langMap.get(langFile), capture);
  });
}
1097832
protected function initTranslations()
    {
        /** @var \yii\i18n\I18N $i18n */
        $i18n = Instance::ensure($this->i18n, \yii\i18n\I18N::class);
        $i18n->translations['recaptcha*'] = [
            'class' => PhpMessageSource::class,
            'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'messages',
            'sourceLanguage' => 'en',
            'fileMap' => [
                'recaptcha' => 'recaptcha.php',
            ],
        ];
    }
596874
private function scanAndSaveTranslations()
    {
        // Scan translations
        $this->info('Scanning codebase and storing all translations');

        $this->strReplaceInFile(config_path('admin-translations.php'),
            '// here you can add your own directories',
            '// here you can add your own directories
        // base_path(\'routes\'), // uncomment if you have translations in your routes i.e. you have localized URLs
        base_path(\'vendor/brackets/admin-auth/src\'),
        base_path(\'vendor/brackets/admin-auth/resources\'),');

        $this->call('admin-translations:scan-and-save', [
            'paths' => array_merge(config('admin-translations.scanned_directories'),
                ['vendor/brackets/admin-auth/src', 'vendor/brackets/admin-auth/resources']),
        ]);
    }
346428
private String translate(final Object messageObject) {
		if (messageObject instanceof Message) {
			Message message = (Message) messageObject;
			return I18nUtilities.format(locale, message.getMessage(), (Object[]) message.getArgs());
		} else if (messageObject != null) {
			return I18nUtilities.format(locale, messageObject.toString());
		}

		return null;
	}
197825
def _extract_translations(self, domains):
        """"""
        for domain, options in domains.items():
            # Create the extractor
            extractor = babel_frontend.extract_messages()
            extractor.initialize_options()
            # The temporary location to write the `.pot` file
            extractor.output_file = options['pot']
            # Add the comments marked with 'tn:' to the translation file for translators to read. Strip the marker.
            extractor.add_comments = ['tn:']
            extractor.strip_comments = True
            # The directory where the sources for this domain are located
            extractor.input_paths = [options['source']]
            # Pass the metadata to the translator
            extractor.msgid_bugs_address = self.manager.args.contact
            extractor.copyright_holder = self.manager.args.copyright
            extractor.version = self.manager.args.version
            extractor.project = self.manager.args.project
            extractor.finalize_options()
            # Add keywords for lazy translation functions, based on their non-lazy variants
            extractor.keywords.update({
                'gettext_lazy': extractor.keywords['gettext'],
                'ngettext_lazy': extractor.keywords['ngettext'],
                '__': extractor.keywords['gettext'],  # double underscore for lazy
            })
            # Do the extraction
            _run_babel_command(extractor)
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);
	}
}