abstractclass AbstractTranslator extendsTranslator
Properties
staticprotectedarray | $singletons | Translator singletons for each language. | |
protectedarray | $messages | List of custom localized messages. | |
protectedstring[] | $directories | List of custom directories that contain translation files. | |
protectedbool | $initializing | Set to true while constructing. | |
protectedstring[] | $aliases | List of locales aliases. |
Methods
Return a singleton instance of Translator.
No description
Returns the list of directories translation files are searched in.
Set list of directories translation files are searched in.
Add a directory to the list translation files are searched in.
Remove a directory from the list translation files are searched in.
Reset messages of a locale (all locale if no locale passed).
Returns the list of files matching a given locale prefix (or all if empty).
Returns the list of internally available locales and already loaded custom locales.
No description
Init messages language from matching file in Lang directory.
Set messages of a locale and take file first if present.
Set messages of the current locale and take file first if present.
Get messages of a locale, if none given, return all the languages.
Set the current translator locale and indicate if the source locale file exists
Show locale on var_dump().
Details
at line68
staticAbstractTranslator
get(string|null$locale =null)
Return a singleton instance of Translator.
at line80
__construct($locale,MessageFormatterInterface$formatter =null,$cacheDir =null,$debug =false)
at line95
array
getDirectories()
Returns the list of directories translation files are searched in.
at line107
$this
setDirectories(array$directories)
Set list of directories translation files are searched in.
at line121
$this
addDirectory(string$directory)
Add a directory to the list translation files are searched in.
at line135
$this
removeDirectory(string$directory)
Remove a directory from the list translation files are searched in.
at line153
bool
resetMessages(string|null$locale =null)
Reset messages of a locale (all locale if no locale passed).
Remove custom messages and reload initial messages from matching file in Lang directory.
at line182
array
getLocalesFiles(string$prefix ='')
Returns the list of files matching a given locale prefix (or all if empty).
at line205
array
getAvailableLocales(string$prefix ='')
Returns the list of internally available locales and already loaded custom locales.
(It will ignore custom translator dynamic loading.)
at line215
protected
translate(string|null$id,array$parameters =[],string|null$domain =null,string|null$locale =null)
at line251
protectedbool
loadMessagesFromFile(string$locale)
Init messages language from matching file in Lang directory.
at line264
$this
setMessages(string$locale,array$messages)
Set messages of a locale and take file first if present.
at line283
$this
setTranslations(array$messages)
Set messages of the current locale and take file first if present.
at line296
array
getMessages(string|null$locale =null)
Get messages of a locale, if none given, return all the languages.
at line308
bool
setLocale(string$locale)
Set the current translator locale and indicate if the source locale file exists
at line372
array
__debugInfo()
Show locale on var_dump().