public static function getInstance()
public static function getInstance()
Return
| wild |
public static function setInstance($instance)
public static function setInstance($instance)
Parameters
| PhutilTranslator | $instance |
Return
| wild |
public function setLocale($locale)
public function setLocale($locale)
Parameters
| PhutilLocale | $locale |
Return
| wild |
public function setWillTranslateCallback($callback)
public function setWillTranslateCallback($callback)
Parameters
| $callback |
Return
| wild |
public function getWillTranslateCallback()
public function getWillTranslateCallback()
Return
| wild |
public function setTranslations($translations)
public function setTranslations($translations)
Add translations which will be later used by translate(). The parameter is an array of strings (for simple translations) or arrays (for translations with variants). The number of items in the array is language specific. It is array($singular, $plural) for English.
array(
'color' => 'colour',
'%d beer(s)' => array('%d beer', '%d beers'),
);The arrays can be nested for strings with more variant parts:
array(
'%d char(s) on %d row(s)' => array(
array('%d char on %d row', '%d char on %d rows'),
array('%d chars on %d row', '%d chars on %d rows'),
),
);The translation should have the same placeholders as originals. Swapping parameter order is possible:
array( '%s owns %s.' => '%2$s is owned by %1$s.', );
Parameters
| array | $translations | Identifier in key, translation in value. |
Return
| PhutilTranslator | Provides fluent interface. |
public function translate($text)
public function translate($text)
Parameters
| $text |
Return
| wild |
private function chooseVariant($translations, $variant)
private function chooseVariant($translations, $variant)
Parameters
| array | $translations | |
| $variant |
Return
| wild |
public function translateDate($format, $date)
public function translateDate($format, $date)
Translate date formatted by $date->format().
Parameters
| string | $format | Format accepted by `DateTime::format()`. |
| DateTime | $date |
Return
| string | Formatted and translated date. |
public function formatNumber($number, $decimals)
public function formatNumber($number, $decimals)
Format number with grouped thousands and optional decimal part. Requires translations of '.' (decimal point) and ',' (thousands separator). Both these translations must be 1 byte long with PHP < 5.4.0.
Parameters
| float | $number | |
| int | $decimals |
Return
| string |
public function validateTranslation($original, $translation)
public function validateTranslation($original, $translation)
Parameters
| $original | ||
| $translation |
Return
| wild |