本文整理汇总了PHP中CBLib\Language\CBTxt::hasText方法的典型用法代码示例。如果您正苦于以下问题:PHP CBTxt::hasText方法的具体用法?PHP CBTxt::hasText怎么用?PHP CBTxt::hasText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBLib\Language\CBTxt
的用法示例。
在下文中一共展示了CBTxt::hasText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: T
/**
* 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 . '*';
}