Class I18n
I18n handles translation of Text and time format strings.
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Located at Cake/I18n/I18n.php
Method Detail
__constructsource public
__construct( )
Constructor, use I18n::getInstance() to get the i18n translation object.
_bindTextDomainsource protected
_bindTextDomain( string $domain )
Binds the given domain to a file in the specified directory.
Parameters
- string
$domain - Domain to bind
Returns
stringDomain binded
_parseLiteralValuesource protected
_parseLiteralValue( string $string )
Auxiliary function to parse a symbol from a locale definition file
Parameters
- string
$string - Symbol to be parsed
Returns
stringparsed symbol
_pluralGuesssource protected
_pluralGuess( string $header , integer $n )
Attempts to find the plural form of a string.
Parameters
- string
$header - Type
- integer
$n - Number
Returns
integerplural match
Link
http://localization-guide.readthedocs.org/en/latest/l10n/pluralforms.htmlhttps://developer.mozilla.org/en-US/docs/Mozilla/Localization/Localization_and_Plurals#List_of_Plural_Rules
_translateTimesource 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
mixedtranslated format string if only value or array of translated strings for corresponding format.
getInstancesource public static
getInstance( )
Return a static instance of the I18n class
Returns
I18nI18n
insertArgssource public static
insertArgs( string $translated , array $args )
Puts the parameters in raw translated strings
Parameters
- string
$translated - The raw translated string
- array
$args - The arguments to put in the translation
Returns
stringTranslated string with arguments
loadLocaleDefinitionsource public static
loadLocaleDefinition( string $filename )
Parses a locale definition file following the POSIX standard
Parameters
- string
$filename - Locale definition filename
Returns
mixedArray of definitions on success or false on failure
loadMosource public static
loadMo( string $filename )
Loads the binary .mo file and returns array of translations
Parameters
- string
$filename - Binary .mo file to load
Returns
mixedArray of translations on success or false on failure
Link
https://www.gnu.org/software/gettext/manual/html_node/MO-Files.htmlloadPosource public static
loadPo( string $filename )
Loads the text .po file and returns array of translations
Parameters
- string
$filename - Text .po file to load
Returns
mixedArray of translations on success or false on failure
translatesource public static
translate( string $singular , string $plural null , string $domain null , string $category I18n::LC_MESSAGES , integer $count null , string $language null , string $context 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
$pluraloptional null - Plural string (if any)
- string
$domainoptional null - Domain The domain of the translation. Domains are often used by plugin translations. If null, the default domain will be used.
- string
$categoryoptionalI18n::LC_MESSAGES - Category The integer value of the category to use.
- integer
$countoptional null - Count Count is used with $plural to choose the correct plural form.
- string
$languageoptional null - Language to translate string to. If null it checks for language in session followed by Config.language configuration variable.
- string
$contextoptional null - Context The context of the translation, e.g a verb or a noun.
Returns
stringtranslated string.
Throws
CakeExceptionWhen '' is provided as a domain.
Constants summary
integer | LC_ALL Constant for LC_ALL. | 0 |
integer | LC_COLLATE Constant for LC_COLLATE. | 1 |
integer | LC_CTYPE Constant for LC_CTYPE. | 2 |
integer | LC_MESSAGES Constant for LC_MESSAGES. | 6 |
integer | LC_MONETARY Constant for LC_MONETARY. | 3 |
integer | LC_NUMERIC Constant for LC_NUMERIC. | 4 |
integer | LC_TIME Constant for LC_TIME. | 5 |
Properties summary
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/2.7/class-I18n.html