PHP Class Gdn_Locale, vanilla

Inheritance: extends Gdn_Pluggable
Afficher le fichier Open project: vanilla/vanilla Class Usage Examples

Méthodes publiques

Свойство Type Description
$DeveloperContainer Core translations, and untranslated codes.
$DeveloperMode Whether or not to record core translations.
$Locale The name of the currently loaded Locale.
$LocaleContainer Holds all locale sources.
$SavedDeveloperCalls integer
$SetLocales array

Méthodes publiques

Méthode Description
__construct ( $LocaleName, $addonManager = null ) Setup the default locale.
canonicalize ( string $locale ) : string Canonicalize a locale string so different representations of the same locale can be used together.
crawlAllLocaleSources ( ) : array Crawl the various addons and locales for all of the applicable translation files.
current ( ) : boolean Returns the name of the currently loaded locale.
getDefinitions ( ) Get all definitions from the loaded locale.
getDeveloperDefinitions ( ) Get all known core.
getLocaleSources ( string $locale ) : array Gets the locale sources for a given locale.
language ( boolean $iso6391 = false ) : boolean | string Return the first 2 letters of the current locale (the language code).
load ( string $Path, boolean $Dynamic = false ) Load a locale definition file.
refresh ( ) Reload the locale and its translations.
saveTranslations ( $Translations, boolean $LocaleName = false )
set ( string $LocaleName ) Defines and loads the locale.
setTranslation ( mixed $Code, string $Translation = '', $Save = false ) Assigns a translation code.
translate ( string $Code, string $Default = false ) : string Translates a code into the selected locale's definition.
unload ( ) Clears out the currently loaded locale settings.

Method Details

__construct() public méthode

Setup the default locale.
public __construct ( $LocaleName, $addonManager = null )
$LocaleName

canonicalize() public static méthode

Example: echo Gdn_Locale::Canonicalize('en-us'); prints en_US
public static canonicalize ( string $locale ) : string
$locale string The locale code to canonicalize.
Résultat string Returns the canonicalized version of the locale code.

crawlAllLocaleSources() public méthode

Crawl the various addons and locales for all of the applicable translation files.
Deprecation: This methods was added to help debug locale canonicalization so should be able to be removed.
public crawlAllLocaleSources ( ) : array
Résultat array Returns an array keyed by locale names where each value is an array of translation paths for that locale.

current() public méthode

Returns the name of the currently loaded locale.
public current ( ) : boolean
Résultat boolean

getDefinitions() public méthode

Get all definitions from the loaded locale.
public getDefinitions ( )

getDeveloperDefinitions() public méthode

Get all known core.

getLocaleSources() public méthode

Gets the locale sources for a given locale.
Deprecation: Use the {@link AddonManager} for this.
public getLocaleSources ( string $locale ) : array
$locale string The name of the locale.
Résultat array Returns an array of paths to the translations for the locale.

language() public méthode

Return the first 2 letters of the current locale (the language code).
public language ( boolean $iso6391 = false ) : boolean | string
$iso6391 boolean Attempt to use ISO 639-1 language codes.
Résultat boolean | string Language code on success, false on failure.

load() public méthode

Load a locale definition file.
public load ( string $Path, boolean $Dynamic = false )
$Path string The path to the locale.
$Dynamic boolean Whether this locale file should be the dynamic one.

refresh() public méthode

Reload the locale and its translations.
public refresh ( )

saveTranslations() public méthode

public saveTranslations ( $Translations, boolean $LocaleName = false )
$Translations
$LocaleName boolean

set() public méthode

Locale definitions are kept in each addon's locale folder. For example: dashboard/locale/$LocaleName.php vanilla/locale/$LocaleName.php
public set ( string $LocaleName )
$LocaleName string The name of the locale to load.

setTranslation() public méthode

These DO NOT PERSIST.
public setTranslation ( mixed $Code, string $Translation = '', $Save = false )
$Code mixed The code to provide a translation for, or an array of code => translation values to be set.
$Translation string The definition associated with the specified code. If $Code is an array of definitions, this value will not be used.

translate() public méthode

Translates a code into the selected locale's definition.
public translate ( string $Code, string $Default = false ) : string
$Code string The code related to the language-specific definition. Codes that begin with an '@' symbol are treated as literals and not translated.
$Default string The default value to be displayed if the translation code is not found.
Résultat string

unload() public méthode

Clears out the currently loaded locale settings.
public unload ( )

Property Details

$DeveloperContainer public_oe property

Core translations, and untranslated codes.
public $DeveloperContainer

$DeveloperMode public_oe property

Whether or not to record core translations.
public $DeveloperMode

$Locale public_oe property

The name of the currently loaded Locale.
public $Locale

$LocaleContainer public_oe property

Holds all locale sources.
public $LocaleContainer

$SavedDeveloperCalls public_oe property

public int $SavedDeveloperCalls
Résultat integer

$SetLocales public_oe static_oe property

public static array $SetLocales
Résultat array