Translator.
Methods
Add remote translations.
addRemoteTranslations(string $type, string $textDomain) : \Zend\I18n\Translator\Translator
Parameters
$type
string
$textDomain
string
Returns
Add a translation file.
addTranslationFile(string $type, string $filename, string $textDomain, string $locale) : \Zend\I18n\Translator\Translator
Parameters
$type
string
$filename
string
$textDomain
string
$locale
string
Returns
Add multiple translations with a file pattern.
addTranslationFilePattern(string $type, string $baseDir, string $pattern, string $textDomain) : \Zend\I18n\Translator\Translator
Parameters
$type
string
$baseDir
string
$pattern
string
$textDomain
string
Returns
Get the fallback locale.
getFallbackLocale() : string
Get the default locale.
getLocale() : string
Exceptions
Returns
string
Check whether the event manager is enabled.
isEventManagerEnabled() : boolean
Translate a message.
translate(string $message, string $textDomain, string $locale) : string
Parameters
$message
string
$textDomain
string
$locale
string
Returns
string
Translate a plural message.
translatePlural(string $singular, string $plural, int $number, string $textDomain, string | null $locale) : string
Parameters
$singular
string
$plural
string
$number
int
$textDomain
string
$locale
stringnull
Exceptions
Returns
string
Get a translated message.
getTranslatedMessage(string $message, string $locale, string $textDomain) : string | null
triggers |
getTranslatedMessage.missing-translation |
Parameters
$message
string
$locale
string
$textDomain
string
Returns
string
null
Load messages for a given language and domain.
loadMessages(string $textDomain, string $locale) : void
triggers |
loadMessages.no-messages-loaded |
Parameters
$textDomain
string
$locale
string
Exceptions
Load messages from files.
loadMessagesFromFiles(string $textDomain, string $locale) : bool
Parameters
$textDomain
string
$locale
string
Exceptions
Returns
bool
Load messages from patterns.
loadMessagesFromPatterns(string $textDomain, string $locale) : bool
Parameters
$textDomain
string
$locale
string
Exceptions
Returns
bool
Load messages from remote sources.
loadMessagesFromRemote(string $textDomain, string $locale) : bool
Parameters
$textDomain
string
$locale
string
Exceptions
Returns
bool
Properties
Whether events are enabled
$eventsEnabled : bool
Locale to use as fallback if there is no translation.
$fallbackLocale : string
Files used for loading messages.
$files : array
Default locale.
$locale : string
Messages loaded by the translator.
$messages : array
Patterns used for loading messages.
$patterns : array
Remote locations for loading messages.
$remote : array
Constants
Event fired when the translation for a message is missing.
EVENT_MISSING_TRANSLATION
Event fired when no messages were loaded for a locale/text-domain combination.
EVENT_NO_MESSAGES_LOADED