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 77
__construct(LoaderInterface $loader, string $language, StoreInterface|null $cache = null)
Constructor.
at line 89
__destruct()
Destructor.
at line 105
LoaderInterface
getLoader()
Returns the language loader.
at line 115
setCache(StoreInterface $cache)
Sets the cache.
at line 125
string
getLanguage()
Gets the current language.
at line 135
setLanguage(string $language)
Sets the current language.
at line 145
protected
loadInflection(string $language)
Loads inflection closure and rules.
at line 158
string
pluralize(string $word, int|null $count = null, string|null $language = null)
Returns the plural form of a noun.
at line 186
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 210
protected array
parseKey(string $key)
Parses the language key.
at line 222
protected bool
loadFromCache(string $language, string $file)
Loads language strings from cache.
at line 235
protected
loadStrings(string $language, string $file)
Loads all strings for the language.
at line 257
protected array
getStrings(string $language, string $file)
Returns all strings from the chosen language file.
at line 274
bool
has(string $key, string|null $language = null)
Returns TRUE if the string exists and FALSE if not.
at line 294
protected string
parsePluralizationTags(string $string)
Pluralize words between pluralization tags.
at line 308
protected string
parseNumberTags(string $string)
Format numbers between number tags.
at line 322
protected string
parseTags(string $string)
Parses tags.
at line 345
string
get(string $key, array $vars = [], string|null $language = null)
Returns the chosen string from the current language.