Page MenuHomePhorge

abstract class PhutilLocale
Arcanist Technical Documentation ()

Defines a locale for translations.

Examples might include "English (US)" or "Japanese".

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.

abstract public function getLocaleCode()

Get the local identifier code, like "en_US".

Return
stringLocale identifier code.

abstract public function getLocaleName()

Get the human-readable locale name, like "English (US)".

Return
stringHuman-readable locale name.

public function getFallbackLocaleCode()

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)".

Return
string|nullLocale code of fallback locale, or null if there is no fallback locale.

public function selectGenderVariant($variant, $translations)

Select a gender variant for this locale. By default, locales use a simple rule with two gender variants, listed in "<male, female>" order.

Parameters
const$variant`PhutilPerson` gender constant.
list<wild>$translationsList of variants.
Return
stringVariant for use.

public function selectPluralVariant($variant, $translations)

Select a plural variant for this locale. By default, locales use a simple rule with two plural variants, listed in "<singular, plural>" order.

Parameters
int$variantPlurality of the value.
list<wild>$translationsList of variants.
Return
stringVariant for use.

public function isSillyLocale()

Flags a locale as silly, like "English (Pirate)".

These locales are fun but disastrously inappropriate for serious businesses.

Return
boolTrue 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.

Return
boolTrue if this is a locale for testing or development.

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)".

Return
boolTrue to postprocess strings.

public function didTranslateString($raw_pattern, $translated_pattern, $args, $result_text)

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.

Parameters
string$raw_patternThe raw input pattern.
string$translated_patternThe selected translation pattern.
list<wild>$argsThe raw input arguments.
string$result_textThe translated string.
Return
stringPost-processed translation string.

public static function loadAllLocales()

Load all available locales.

Return
map<string, PhutilLocale>Map from codes to locale objects.

public static function loadLocale($locale_code)

Load a specific locale using a locale code.

Parameters
string$locale_codeLocale code.
Return
PhutilLocaleLocale object.

private static function checkLocaleFallback($map, $locale, $seen)

Recursively check locale fallbacks for cycles.

Parameters
map<string,$mapPhutilLocale> Map of locales.
PhutilLocale$localeCurrent locale.
map<string,$seenstring> Map of visited locales.
Return
void