Class I18n
I18n handles translation of Text and time format strings.
Copyright: Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: Cake/I18n/I18n.php
Properties summary
-
$_categories
protectedarray
Set to true when I18N::_bindTextDomain() is called for the first time. If a translation file is found it is set to false again
-
$_domains
protectedarray
Translation strings for a specific domain read from the .mo or .po files -
$_lang
protectedstring
Current language used for translations -
$_noLocale
protectedboolean
Set to true when I18N::_bindTextDomain() is called for the first time. If a translation file is found it is set to false again
-
$category
publicstring
Current category of translation -
$domain
publicstring
Current domain of translation -
$l10n
publicInstance of the L10n class for localization
Method Summary
-
__construct() public
Constructor, use I18n::getInstance() to get the i18n translation object. -
_bindTextDomain() protected
Binds the given domain to a file in the specified directory. -
_loadLocaleDefinition() protected
Parses a locale definition file following the POSIX standard -
_loadMo() protected
Loads the binary .mo file for translation and sets the values for this translation in the var I18n::_domains -
_loadPo() protected
Loads the text .po file for translation and sets the values for this translation in the var I18n::_domains -
_parseLiteralValue() protected
Auxiliary function to parse a symbol from a locale definition file -
_pluralGuess() protected
Attempts to find the plural form of a string. -
_translateTime() protected
Returns a Time format definition from corresponding domain -
clear() public static
Clears the domains internal data array. Useful for testing i18n. -
domains() public static
Get the loaded domains cache. -
getInstance() public static
Return a static instance of the I18n class -
translate() public static
Used by the translation functions in basics.php Returns a translated string based on current language and translation files stored in locale folder
Method Detail
__construct() public ¶
__construct( )
Constructor, use I18n::getInstance() to get the i18n translation object.
_bindTextDomain() protected ¶
_bindTextDomain( string $domain )
Binds the given domain to a file in the specified directory.
Parameters
- string $domain
- Domain to bind
Returns
Domain binded
_loadLocaleDefinition() protected ¶
_loadLocaleDefinition( resource $file , string $domain = null )
Parses a locale definition file following the POSIX standard
Parameters
- resource $file
- file handler
- string $domain optional null
- Domain where locale definitions will be stored
_loadMo() protected ¶
_loadMo( string $file , string $domain )
Loads the binary .mo file for translation and sets the values for this translation in the var I18n::_domains
Parameters
- string $file
- Binary .mo file to load
- string $domain
- Domain where to load file in
_loadPo() protected ¶
_loadPo( resource $file , string $domain )
Loads the text .po file for translation and sets the values for this translation in the var I18n::_domains
Parameters
- resource $file
- Text .po file to load
- string $domain
- Domain to load file in
Returns
Binded domain elements
_parseLiteralValue() protected ¶
_parseLiteralValue( string $string )
Auxiliary function to parse a symbol from a locale definition file
Parameters
- string $string
- Symbol to be parsed
Returns
parsed symbol
_pluralGuess() protected ¶
_pluralGuess( string $header , integer $n )
Attempts to find the plural form of a string.
Parameters
- string $header
- Type
- integer $n
- Number
Returns
plural match
_translateTime() protected ¶
_translateTime( string $format , string $domain )
Returns a Time format definition from corresponding domain
Parameters
- string $format
- Format to be translated
- string $domain
- Domain where format is stored
Returns
translated format string if only value or array of translated strings for corresponding format.
translate() public static ¶
translate( string $singular , string $plural = null , string $domain = null , string $category = 6 , integer $count = null )
Used by the translation functions in basics.php Returns a translated string based on current language and translation files stored in locale folder
Parameters
- string $singular
- String to translate
- string $plural optional null
- Plural string (if any)
- string $domain optional null
- Domain The domain of the translation. Domains are often used by plugin translations
- string $category optional 6
- Category The integer value of the category to use.
- integer $count optional null
- Count Count is used with $plural to choose the correct plural form.
Returns
translated string.
Properties detail
$_categories ¶
Set to true when I18N::_bindTextDomain() is called for the first time. If a translation file is found it is set to false again
array( 'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', 'LC_MESSAGES' )
$_domains ¶
Translation strings for a specific domain read from the .mo or .po files
array()
$_noLocale ¶
Set to true when I18N::_bindTextDomain() is called for the first time. If a translation file is found it is set to false again
false