I18n¶
- class Nos\I18n¶
Provides the translation related functions.
::setLocale()¶
- static Nos\I18n::setLocale($locale)¶
Configure the locale to use for translations.
Parameters: - $locale (string) – A valid locale (en, en_GB, en_GB.utf-8 and en_GB.utf-8@variant are all valid).
::load()¶
- static Nos\I18n::load($file)¶
Loads a dictionary for the current locale.
Parameters: - $file (string) – dictionary path.
::get()¶
- static Nos\I18n::get($message, $default = null)¶
Retrieves a translation from the last loaded dictionary.
Parameters: - $message (string) – The message to translate.
- $default (string) – The default text to return when the message is not found. Default value is the message itself.
::gget()¶
- static Nos\I18n::gget($file, $message, $default = null)¶
Retrieves a translation from a specific dictionary.
Parameters: - $file (string) – Which dictionary to look into.
- $message (string) – The message to translate.
- $default (string) – The default text to return when the message is not found. Default value is the message itself.
Warning
The dictionary must have been loaded manually before.
::dictionary()¶
- static Nos\I18n::dictionary($files)¶
Returns a closure that translate messages from a specific dictionary.
param string|array $files: A dictionary file or list of dictionaries. <?php // Retrieves an anonymous function $dictionary = Nos\I18n::dictionary('mon_appli::common'); echo $dictionary('Translate this');