LoggingTranslator
in package
implements
TranslatorInterface, TranslatorInterface, TranslatorBagInterface
Tags
Interfaces, Classes, Traits and Enums
- TranslatorInterface
- TranslatorInterface
- TranslatorInterface.
- TranslatorBagInterface
- TranslatorBagInterface.
Table of Contents
- $logger : mixed
- $translator : TranslatorInterface|TranslatorBagInterface
- __call() : mixed
- Passes through all unknown calls onto the translator object.
- __construct() : mixed
- getCatalogue() : MessageCatalogueInterface
- Gets the catalogue by locale.
- getFallbackLocales() : array<string|int, mixed>
- Gets the fallback locales.
- getLocale() : string
- Returns the current locale.
- setLocale() : mixed
- Sets the current locale.
- trans() : string
- Translates the given message.
- transChoice() : string
- Translates the given choice message by choosing a translation according to a number.
- log() : mixed
- Logs for missing translations.
Properties
$logger
private
mixed
$logger
$translator
private
TranslatorInterface|TranslatorBagInterface
$translator
Methods
__call()
Passes through all unknown calls onto the translator object.
public
__call(mixed $method, mixed $args) : mixed
Parameters
- $method : mixed
- $args : mixed
Return values
mixed —__construct()
public
__construct(TranslatorInterface $translator, LoggerInterface $logger) : mixed
Parameters
- $translator : TranslatorInterface
-
The translator must implement TranslatorBagInterface
- $logger : LoggerInterface
Return values
mixed —getCatalogue()
Gets the catalogue by locale.
public
getCatalogue([mixed $locale = null ]) : MessageCatalogueInterface
Parameters
- $locale : mixed = null
-
The locale or null to use the default
Return values
MessageCatalogueInterface —getFallbackLocales()
Gets the fallback locales.
public
getFallbackLocales() : array<string|int, mixed>
Return values
array<string|int, mixed> —The fallback locales
getLocale()
Returns the current locale.
public
getLocale() : string
Return values
string —The locale
setLocale()
Sets the current locale.
public
setLocale(mixed $locale) : mixed
Parameters
- $locale : mixed
-
The locale
Return values
mixed —trans()
Translates the given message.
public
trans(mixed $id[, array<string|int, mixed> $parameters = [] ][, mixed $domain = null ][, mixed $locale = null ]) : string
Parameters
- $id : mixed
-
The message id (may also be an object that can be cast to string)
- $parameters : array<string|int, mixed> = []
-
An array of parameters for the message
- $domain : mixed = null
-
The domain for the message or null to use the default
- $locale : mixed = null
-
The locale or null to use the default
Return values
string —The translated string
transChoice()
Translates the given choice message by choosing a translation according to a number.
public
transChoice(mixed $id, mixed $number[, array<string|int, mixed> $parameters = [] ][, mixed $domain = null ][, mixed $locale = null ]) : string
Parameters
- $id : mixed
-
The message id (may also be an object that can be cast to string)
- $number : mixed
-
The number to use to find the index of the message
- $parameters : array<string|int, mixed> = []
-
An array of parameters for the message
- $domain : mixed = null
-
The domain for the message or null to use the default
- $locale : mixed = null
-
The locale or null to use the default
Tags
Return values
string —The translated string
log()
Logs for missing translations.
private
log(string|null $id, string|null $domain, string|null $locale) : mixed
Parameters
- $id : string|null
- $domain : string|null
- $locale : string|null