I18n
class I18n extends AbstractSingleton implements TranslatableInterface
Internationalization class
For more information, see: - http://www.unicode.org/reports/tr35/ - http://userguide.icu-project.org/locale - http://userguide.icu-project.org/formatparse/datetime - http://www.php.net/manual/en/book.intl.php
Methods
Gets the loader
Load a new language file
Loads a new language
Get the current language code used
Try to get the browser default locale and use it
Check if a language code is available in the Loader
Get the full locale info for a language code
Get the list of Loader::available_languages
Get the current locale used by the system
Define a new timezone for the system
Get the current timezone used by the system
Check if a translation exists for an index
Get the translation of an index
Parse a translated string making some parameters replacements
Get the meta-data of a language string
Get the currency of the current locale
Get the browser requested locale if so
Get the full list of Loader::available_languages
option like human readable names
Get the language code of the current locale
Get the region code of the current locale
Get the script code of the current locale
Get the keywords of the current locale
Get one keyword value of the current locale
Get the primary language of a locale
Get the language name of a locale
Get the country name of a locale
Get the script name of a locale
Get the variant name of a locale
Get a localized number value
Get a localized price value
Get a localized date value
Process a translation with arguments
Process a translation with arguments depending on a counter
Details
at line 212
I18n
setLoader(
LoaderInterface $loader)
Store the loader
at line 223
LoaderInterface
getLoader()
Gets the loader
at line 235
loadFile(
string $file_name,
null|string $dir_name = null)
Load a new language file
at line 273
I18n
setLanguage(
string $lang,
bool $throw_errors = true,
bool $force_rebuild = false)
Loads a new language
This will actually define a new default Locale and load the language strings database.
at line 293
string
getLanguage()
Get the current language code used
at line 303
I18n
setDefaultFromHttp()
Try to get the browser default locale and use it
at line 318
bool
isAvailableLanguage(
string $lang)
Check if a language code is available in the Loader
at line 333
null|string
getAvailableLocale(
string $lang)
Get the full locale info for a language code
This will look in the Loader::available_languages
option to retrieve the full
locale string corresponding to a language code.
at line 349
array
getAvailableLanguages()
Get the list of Loader::available_languages
at line 363
I18n
setLocale(
string $locale)
Define a new locale for the system
at line 374
string
getLocale()
Get the current locale used by the system
at line 385
I18n
setTimezone(
string $timezone)
Define a new timezone for the system
at line 397
string
getTimezone()
Get the current timezone used by the system
at line 408
bool
hasLocalizedString(
string $index)
Check if a translation exists for an index
at line 419
string
getLocalizedString(
string $index)
Get the translation of an index
at line 432
string
parseString(
string $str,
array $arguments = null)
Parse a translated string making some parameters replacements
at line 454
array
parseStringMetadata(
string $str)
Get the meta-data of a language string
at line 503
string
getCurrency(
string $lang = null)
Get the currency of the current locale
at line 522
string
getHttpHeaderLocale()
Get the browser requested locale if so
at line 534
array
getAvailableLanguagesNames(
string $lang = null)
Get the full list of Loader::available_languages
option like human readable names
at line 559
string
getLanguageCode(
string $lang = null)
Get the language code of the current locale
at line 571
string
getRegionCode(
string $lang = null)
Get the region code of the current locale
at line 582
string
getScriptCode(
string $lang = null)
Get the script code of the current locale
at line 593
array
getKeywords(
string $lang = null)
Get the keywords of the current locale
at line 605
null|string
getKeyword(
string $keyword,
string $lang = null)
Get one keyword value of the current locale
at line 618
string
getPrimaryLanguage(
string $for_locale = null,
string $lang = null)
Get the primary language of a locale
at line 630
string
getLanguageName(
string $for_locale = null,
string $lang = null)
Get the language name of a locale
at line 642
string
getCountryName(
string $for_locale = null,
string $lang = null)
Get the country name of a locale
at line 654
string
getLocaleScript(
string $for_locale = null,
string $lang = null)
Get the script name of a locale
at line 666
string
getLocaleVariant(
string $for_locale = null,
string $lang = null)
Get the variant name of a locale
at line 710
static
string
getLocalizedNumberString(
int $number,
string $lang = null)
Get a localized number value
This is called by aliases _N
and numberify
.
at line 736
static
string
getLocalizedPriceString(
int $number,
string $lang = null)
Get a localized price value
This is called by aliases _C
and currencify
.
at line 765
static
string
getLocalizedDateString(
DateTime $date,
string $mask = null,
string $charset = 'UTF-8',
string $lang = null)
Get a localized date value
This is called by aliases _D
and datify
.
at line 817
static
string
translate(
string $index,
array $args = null,
string $lang = null)
Process a translation with arguments
This is the core method of the class: it searches the translation of $index
in the
current language, rebuilds it replacing the keys of $args
by their values and returns
the corresponding localized translated string.
This is called by aliases _T
and translate
.
at line 859
static
string
pluralize(
array $indexes = array(),
int $number,
array $args = null,
string $lang = null)
Process a translation with arguments depending on a counter
This will first choose in $indexes
the corresponding value for the counter $number
and then process the translation of the chosen string with arguments.
This is called by aliases _P
and pluralize
.