PHP Class Gdn_Locale, vanilla

Inheritance: extends Gdn_Pluggable
Mostra file Open project: vanilla/vanilla Class Usage Examples

Public Properties

Property 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

Public Methods

Method 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 method

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

canonicalize() public static method

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

crawlAllLocaleSources() public method

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
return array Returns an array keyed by locale names where each value is an array of translation paths for that locale.

current() public method

Returns the name of the currently loaded locale.
public current ( ) : boolean
return boolean

getDefinitions() public method

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

getDeveloperDefinitions() public method

Get all known core.

getLocaleSources() public method

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.
return array Returns an array of paths to the translations for the locale.

language() public method

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.
return boolean | string Language code on success, false on failure.

load() public method

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 method

Reload the locale and its translations.
public refresh ( )

saveTranslations() public method

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

set() public method

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 method

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 method

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.
return string

unload() public method

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
return integer

$SetLocales public_oe static_oe property

public static array $SetLocales
return array