LoggingTranslator
in package
implements
TranslatorInterface, TranslatorBagInterface, LocaleAwareInterface
Tags
Table of Contents
Interfaces
Properties
- $logger : mixed
- $translator : mixed
Methods
- __call() : mixed
- Passes through all unknown calls onto the translator object.
- __construct() : mixed
- getCatalogue() : MessageCatalogueInterface
- Gets the catalogue by locale.
- getCatalogues() : array<string|int, MessageCatalogueInterface>
- Returns all catalogues of the instance.
- getFallbackLocales() : array<string|int, mixed>
- Gets the fallback locales.
- getLocale() : string
- Returns the default locale.
- setLocale() : mixed
- Sets the current locale.
- trans() : string
- Translates the given message.
- log() : mixed
- Logs for missing translations.
Properties
$logger
private
mixed
$logger
$translator
private
mixed
$translator
Methods
__call()
Passes through all unknown calls onto the translator object.
public
__call(string $method, array<string|int, mixed> $args) : mixed
Parameters
- $method : string
- $args : array<string|int, mixed>
__construct()
public
__construct(TranslatorInterface|TranslatorBagInterface|LocaleAwareInterface $translator, LoggerInterface $logger) : mixed
Parameters
- $translator : TranslatorInterface|TranslatorBagInterface|LocaleAwareInterface
-
The translator must implement TranslatorBagInterface
- $logger : LoggerInterface
getCatalogue()
Gets the catalogue by locale.
public
getCatalogue([string $locale = null ]) : MessageCatalogueInterface
Parameters
- $locale : string = null
-
The locale or null to use the default
Return values
MessageCatalogueInterfacegetCatalogues()
Returns all catalogues of the instance.
public
getCatalogues() : array<string|int, MessageCatalogueInterface>
Return values
array<string|int, MessageCatalogueInterface>getFallbackLocales()
Gets the fallback locales.
public
getFallbackLocales() : array<string|int, mixed>
Return values
array<string|int, mixed>getLocale()
Returns the default locale.
public
getLocale() : string
Return values
stringsetLocale()
Sets the current locale.
public
setLocale(string $locale) : mixed
Parameters
- $locale : string
trans()
Translates the given message.
public
trans(string|null $id[, array<string|int, mixed> $parameters = [] ][, string $domain = null ][, string $locale = null ]) : string
Parameters
- $id : string|null
-
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 : string = null
-
The domain for the message or null to use the default
- $locale : string = null
-
The locale or null to use the default
Return values
stringlog()
Logs for missing translations.
private
log(string $id, string|null $domain, string|null $locale) : mixed
Parameters
- $id : string
- $domain : string|null
- $locale : string|null