Class PhutilTranslator
Tasks
Methods
public PhutilTranslator addTranslations(array $translations)
| parameters | array | $translations | Identifier in key, translation in value. |
| return | PhutilTranslator | | Provides fluent interface. |
Add translations which will be later used by translate().
The parameter is an array of strings (for simple translations) or arrays
(for translastions with variants). The number of items in the array is
language specific. It is array($singular, $plural) for English.
The arrays can be nested for strings with more variant parts:
The translation should have the same placeholders as originals. Swapping
parameter order is possible:
private chooseVariant(array $translations, $variant)
| parameters | array | $translations | |
| wild | $variant | |
| return | wild | | |
This method is not documented.
public string formatNumber($number, $decimals = 0)
| parameters | float | $number | |
| int | $decimals | |
| return | string | | |
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.
public static getInstance()
This method is not documented.
public static setInstance(PhutilTranslator $instance)
| parameters | PhutilTranslator | $instance | |
| return | wild | | |
This method is not documented.
public setLanguage($language)
| parameters | wild | $language | |
| return | wild | | |
This method is not documented.
public translate($text)
| parameters | wild | $text | |
| return | wild | | |
This method is not documented.
public string translateDate($format, DateTime $date)
| parameters | string | $format | Format accepted by DateTime::format(). |
| DateTime | $date | |
| return | string | | Formatted and translated date. |
Translate date formatted by $date->format().
public validateTranslation($original, $translation)
| parameters | wild | $original | |
| wild | $translation | |
| return | wild | | |
This method is not documented.