I18n
class I18n
Internationalization class.
Properties
protected LoaderInterface | $loader | Language loader. | |
protected string | $language | Current language. | |
protected array | $strings | Loaded language strings. | |
protected array | $inflections | Loaded language inflections. | |
protected StoreInterface | $cache | Cache instance. | |
protected bool | $rebuildCache | Should we rebuild the cache? |
Methods
Constructor.
Destructor.
Returns the language loader.
Gets the current language.
Sets the current language.
Loads inflection closure and rules.
Returns the plural form of a noun.
Format number according to locale or desired format.
Parses the language key.
Loads language strings from cache.
Loads all strings for the language.
Returns all strings from the chosen language file.
Returns TRUE if the string exists and FALSE if not.
Pluralize words between pluralization tags.
Format numbers between number tags.
Parses tags.
Returns the chosen string from the current language.
Details
at line 79
__construct(LoaderInterface $loader, string $language, StoreInterface|null $cache = null)
Constructor.
at line 91
__destruct()
Destructor.
at line 107
LoaderInterface
getLoader()
Returns the language loader.
at line 117
setCache(StoreInterface $cache)
Sets the cache.
at line 127
string
getLanguage()
Gets the current language.
at line 137
setLanguage(string $language)
Sets the current language.
at line 147
protected
loadInflection(string $language)
Loads inflection closure and rules.
at line 161
string
pluralize(string $word, int|null $count = null, string|null $language = null)
Returns the plural form of a noun.
at line 189
string
number(float $number, int $decimals = 0, string|null $decimalPoint = null, string|null $thousandsSeparator = null)
Format number according to locale or desired format.
at line 213
protected array
parseKey(string $key)
Parses the language key.
at line 225
protected bool
loadFromCache(string $language, string $file)
Loads language strings from cache.
at line 238
protected
loadStrings(string $language, string $file)
Loads all strings for the language.
at line 260
protected array
getStrings(string $language, string $file)
Returns all strings from the chosen language file.
at line 277
bool
has(string $key, string|null $language = null)
Returns TRUE if the string exists and FALSE if not.
at line 297
protected string
parsePluralizationTags(string $string)
Pluralize words between pluralization tags.
at line 311
protected string
parseNumberTags(string $string)
Format numbers between number tags.
at line 325
protected string
parseTags(string $string)
Parses tags.
at line 348
string
get(string $key, array $vars = [], string|null $language = null)
Returns the chosen string from the current language.