public function getLocaleCode()
Get the local identifier code, like "en_US".
string | Locale identifier code. |
public function getLocaleName()
Get the human-readable locale name, like "English (US)".
string | Human-readable locale name. |
public function getFallbackLocaleCode()Inherited
Set a fallback locale which can be used as a default if this locale is missing translations.
For locales like "English (Great Britain)", missing translations can be sourced from "English (US)".
string|null | Locale code of fallback locale, or null if there is no fallback locale. |
public function selectGenderVariant($variant, $translations)Inherited
Select a gender variant for this locale. By default, locales use a simple rule with two gender variants, listed in "<male, female>" order.
const | $variant | `PhutilPerson` gender constant. |
list<wild> | $translations | List of variants. |
string | Variant for use. |
public function selectPluralVariant($variant, $translations)Inherited
Select a plural variant for this locale. By default, locales use a simple rule with two plural variants, listed in "<singular, plural>" order.
int | $variant | Plurality of the value. |
list<wild> | $translations | List of variants. |
string | Variant for use. |
public function isSillyLocale()Inherited
Flags a locale as silly, like "English (Pirate)".
These locales are fun but disastrously inappropriate for serious businesses.
bool | True if this locale is silly. |
public function isTestLocale()
Flags a locale as a testing locale, like "English (US, ALL CAPS)". These locales are useful for translation development, but not for normal users.
bool | True if this is a locale for testing or development. |
public function shouldPostProcessTranslations()Inherited
Indicates that the translator should post-process translations in this locale by calling didTranslateString().
Doing this incurs a performance penalty, and is not useful for most languages. However, it can be used to implement test translations like "English (US, ALL CAPS)".
bool | True to postprocess strings. |
public function didTranslateString($raw_pattern, $translated_pattern, $args, $result_text)Inherited
Callback for post-processing translations.
By default, this callback is not invoked. To activate it, return true from shouldPostProcessTranslations(). Activating this callback incurs a performance penalty.
string | $raw_pattern | The raw input pattern. |
string | $translated_pattern | The selected translation pattern. |
list<wild> | $args | The raw input arguments. |
string | $result_text | The translated string. |
string | Post-processed translation string. |
public static function loadAllLocales()Inherited
Load all available locales.
map<string, PhutilLocale> | Map from codes to locale objects. |
public static function loadLocale($locale_code)Inherited
Load a specific locale using a locale code.
string | $locale_code | Locale code. |
PhutilLocale | Locale object. |
private static function checkLocaleFallback($map, $locale, $seen)Inherited
Recursively check locale fallbacks for cycles.
map<string, | $map | PhutilLocale> Map of locales. |
PhutilLocale | $locale | Current locale. |
map<string, | $seen | string> Map of visited locales. |
void |