public function __get($name)Inherited
$name |
wild |
public function __set($name, $value)Inherited
$name | ||
$value |
wild |
public function current()Inherited
wild |
public function key()Inherited
wild |
public function next()Inherited
wild |
public function rewind()Inherited
wild |
public function valid()Inherited
wild |
private function throwOnAttemptedIteration()Inherited
wild |
public function getPhobjectClassConstant($key, $byte_limit)Inherited
Read the value of a class constant.
This is the same as just typing self::CONSTANTNAME, but throws a more useful message if the constant is not defined and allows the constant to be limited to a maximum length.
string | $key | Name of the constant. |
int|null | $byte_limit | Maximum number of bytes permitted in the value. |
string | Value of the constant. |
public static function getInstance()
wild |
public static function setInstance($instance)
PhutilTranslator | $instance |
wild |
public function setLocale($locale)
PhutilLocale | $locale |
wild |
public function setWillTranslateCallback($callback)
$callback |
wild |
public function getWillTranslateCallback()
wild |
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.', );
array | $translations | Identifier in key, translation in value. |
PhutilTranslator | Provides fluent interface. |
public function translate($text)
$text |
wild |
private function chooseVariant($translations, $variant)
array | $translations | |
$variant |
wild |
public function translateDate($format, $date)
Translate date formatted by $date->format().
string | $format | Format accepted by `DateTime::format()`. |
DateTime | $date |
string | Formatted and translated date. |
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.
float | $number | |
int | $decimals |
string |
public function validateTranslation($original, $translation)
$original | ||
$translation |
wild |