Page MenuHomePhorge

final class PhutilTranslator
libphutil Technical Documentation (Internationalization)

This class is not documented.

Methods

public function __get($name)
Inherited

This method is not documented.
Parameters
$name
Return
wild

public function __set($name, $value)
Inherited

This method is not documented.
Parameters
$name
$value
Return
wild

public function current()
Inherited

This method is not documented.
Return
wild

public function key()
Inherited

This method is not documented.
Return
wild

public function next()
Inherited

This method is not documented.
Return
wild

public function rewind()
Inherited

This method is not documented.
Return
wild

public function valid()
Inherited

This method is not documented.
Return
wild

private function throwOnAttemptedIteration()
Inherited

This method is not documented.
Return
wild

public function getPhobjectClassConstant($key, $byte_limit)
Inherited

Phobject

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.

Parameters
string$keyName of the constant.
int|null$byte_limitMaximum number of bytes permitted in the value.
Return
stringValue of the constant.

public static function getInstance()

This method is not documented.
Return
wild

public static function setInstance($instance)

This method is not documented.
Parameters
PhutilTranslator$instance
Return
wild

public function setLocale($locale)

This method is not documented.
Parameters
PhutilLocale$locale
Return
wild

public function setWillTranslateCallback($callback)

This method is not documented.
Parameters
$callback
Return
wild

public function getWillTranslateCallback()

This method is not documented.
Return
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.',
);
Parameters
array$translationsIdentifier in key, translation in value.
Return
PhutilTranslatorProvides fluent interface.

public function translate($text)

This method is not documented.
Parameters
$text
Return
wild

private function chooseVariant($translations, $variant)

This method is not documented.
Parameters
array$translations
$variant
Return
wild

public function translateDate($format, $date)

Translate date formatted by $date->format().

Parameters
string$formatFormat accepted by `DateTime::format()`.
DateTime$date
Return
stringFormatted 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.

Parameters
float$number
int$decimals
Return
string

public function validateTranslation($original, $translation)

This method is not documented.
Parameters
$original
$translation
Return
wild