Example #1
0
 /**
  * T like Translate text from english to target language
  * (can add translation markers in TEXT for display in language debug mode)
  *
  * Multiple keys can be given if string starts with *, and will be tried from left to right until English string at right, E.g. as follows:
  * T( '*REGISTRATION_SIGN-UP_TITLE*REGISTRATION_SIGN-UP*Sign-up' );
  * This allows to translate or override specific texts, or generally.
  *
  * Variables substitution is performed for the $args parameter.
  *
  * The message supports two different types of pluralization rules:
  *
  * interval: {0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples
  * indexed:  There is one apple|There are %count% apples
  *
  * The indexed solution can also contain labels (e.g. one: There is one apple).
  * This is purely for making the translations more clear - it does not
  * affect the functionality.
  *
  * The two methods can also be mixed:
  *     {0} There are no apples|one: There is one apple|more: There are %count% apples
  *
  * @param  string  $languageKeys   Key(s) separated by space. Or if second argument is empty, English string
  *                                 (e.g. 'KEY1-DETAILED KEY2-GENERAL')
  * @param  string  $englishString  The English string to use if no translations found
  * @param  array   $args           A strtr-formatted array of string substitutions
  * @return string                  Translated string
  *
  * @throws \InvalidArgumentException
  */
 public static function T($languageKeys, $englishString = null, array $args = array())
 {
     if ($languageKeys == '') {
         return $languageKeys;
     }
     $translated = static::$self->translateToCurrentLanguage($languageKeys, $englishString, $args);
     if (static::$self->mode == 0) {
         return $translated;
     }
     if (!static::$self->hasText($languageKeys)) {
         return $languageKeys;
     }
     $isTranslated = !is_null(static::$self->lastKeyUsed);
     static::$self->translationsLogger->recordUsedString($languageKeys, static::$self->lastKeyUsed, static::$self->lastAutoKey, $englishString, $isTranslated ? $translated : null);
     if (!$isTranslated) {
         return '===\\' . $translated . '/---';
     }
     return '*' . $translated . '*';
 }