$registry
$registry : array
A registry to retain translator objects.
Constructs and stores instances of translators that can be retrieved by name and locale.
$factory : \Aura\Intl\TranslatorFactory
A translator factory.
$packages : \Aura\Intl\PackageLocator
A package locator.
$formatters : \Aura\Intl\FormatterLocator
A formatter locator.
$_cacher : \Cake\Cache\CacheEngine
A CacheEngine object that is used to remember translator across requests.
__construct(\Aura\Intl\PackageLocator $packages, \Aura\Intl\FormatterLocator $formatters, \Cake\I18n\TranslatorFactory $factory, string $locale)
Constructor.
\Aura\Intl\PackageLocator | $packages | The package locator. |
\Aura\Intl\FormatterLocator | $formatters | The formatter locator. |
\Cake\I18n\TranslatorFactory | $factory | A translator factory to create translator objects for the locale and package. |
string | $locale | The default locale code to use. |
getFactory() : \Aura\Intl\TranslatorFactory
The TranslatorFactory object
getPackages() : \Aura\Intl\PackageLocator
An object of type PackageLocator
getFormatters() : \Aura\Intl\FormatterLocator
An object of type FormatterLocator
get(string $name, string|null $locale = null) : \Aura\Intl\TranslatorInterface|null
Gets a translator from the registry by package for a locale.
string | $name | The translator package to retrieve. |
string|null | $locale | The locale to use; if empty, uses the default locale. |
If no translator with that name could be found for the given locale.
A translator object.
setCacher(\Cake\Cache\CacheEngine $cacher) : void
Sets the CacheEngine instance used to remember translators across requests.
\Cake\Cache\CacheEngine | $cacher | The cacher instance. |
registerLoader(string $name, callable $loader) : void
Registers a loader function for a package name that will be used as a fallback in case no package with that name can be found.
Loader callbacks will get as first argument the package name and the locale as the second argument.
string | $name | The name of the translator package to register a loader for |
callable | $loader | A callable object that should return a Package |
defaultFormatter(string|null $name = null) : string
Sets the name of the default messages formatter to use for future translator instances.
If called with no arguments, it will return the currently configured value.
string|null | $name | The name of the formatter to use. |
The name of the formatter.
_getTranslator(string $name, string|null $locale) : \Aura\Intl\TranslatorInterface
Gets a translator from the registry by package for a locale.
string | $name | The translator package to retrieve. |
string|null | $locale | The locale to use; if empty, uses the default locale. |
A translator object.
_fallbackLoader(string $name, string $locale) : \Aura\Intl\Translator
Returns a new translator instance for the given name and locale based of conventions.
string | $name | The translation package name. |
string | $locale | The locale to create the translator for. |
_getFromLoader(string $name, string $locale) : \Aura\Intl\TranslatorInterface
Registers a new package by passing the register loaded function for the package name.
string | $name | The name of the translator package |
string | $locale | The locale that should be built the package for |
A translator object.
Loading…