Constructs and stores instances of translators that can be retrieved by name and locale.
(\Psr\SimpleCache\CacheInterface&\Cake\Cache\CacheEngineInterface)|nullA CacheEngine object that is used to remember translator across requests.
stringThe name of the default formatter to use for newly created translators from the fallback loader
stringFallback loader name
callable[]A list of loader functions indexed by domain name. Loaders are callables that are invoked as a default for building translation packages where none can be found for the combination of translator name and locale.
boolUse fallback-domain for translation loaders.
\Aura\Intl\TranslatorFactoryA translator factory.
\Aura\Intl\FormatterLocatorA formatter locator.
stringThe current locale code.
\Aura\Intl\PackageLocatorA package locator.
arrayA registry to retain translator objects.
Returns a new translator instance for the given name and locale based of conventions.
Registers a new package by passing the register loaded function for the package name.
Returns a function that can be used as a loader for the registerLoaderMethod
Sets the name of the default messages formatter to use for future translator instances.
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.
__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.
_fallbackLoader(string $name, string $locale)
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.
\Aura\Intl\TranslatorInterface|\Closure_getFromLoader(string $name, string $locale)
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
\Aura\Intl\TranslatorInterfaceA translator object.
_getTranslator(string $name, string $locale)
Gets a translator from the registry by package for a locale.
string $name The translator package to retrieve.
string $locale The locale to use; if empty, uses the default locale.
\Aura\Intl\TranslatorInterfaceA translator object.
_partialLoader()
Returns a function that can be used as a loader for the registerLoaderMethod
\ClosuredefaultFormatter(?string $name)
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 optional The name of the formatter to use.
stringThe name of the formatter.
get(mixed $name, mixed $locale)
Gets a translator from the registry by package for a locale.
string|null $name The translator package to retrieve.
string|null $locale optional The locale to use; if empty, uses the default locale.
\Aura\Intl\TranslatorInterface|nullA translator object.
Aura\Intl\ExceptiongetFactory()
The TranslatorFactory object
\Aura\Intl\TranslatorFactorygetFormatters()
An object of type FormatterLocator
\Aura\Intl\FormatterLocatorgetLocale()
Returns the default locale code.
stringgetPackages()
An object of type PackageLocator
\Aura\Intl\PackageLocatorregisterLoader(string $name, callable $loader)
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
setCacher(mixed $cacher)
Sets the CacheEngine instance used to remember translators across requests.
\Psr\SimpleCache\CacheInterface&\Cake\Cache\CacheEngineInterface $cacher The cacher instance.
setLoaderFallback(string $name, callable $loader)
Set domain fallback for loader.
string $name The name of the loader domain
callable $loader invokable loader
callableloader
setLocale(mixed $locale)
Sets the default locale code.
string $locale The new locale code.
useFallback(bool $enable)
Set if the default domain fallback is used.
bool $enable optional flag to enable or disable fallback
A CacheEngine object that is used to remember translator across requests.
(\Psr\SimpleCache\CacheInterface&\Cake\Cache\CacheEngineInterface)|nullThe name of the default formatter to use for newly created translators from the fallback loader
stringFallback loader name
stringA list of loader functions indexed by domain name. Loaders are callables that are invoked as a default for building translation packages where none can be found for the combination of translator name and locale.
callable[]Use fallback-domain for translation loaders.
boolA translator factory.
\Aura\Intl\TranslatorFactoryA formatter locator.
\Aura\Intl\FormatterLocatorThe current locale code.
stringA package locator.
\Aura\Intl\PackageLocatorA registry to retain translator objects.
array
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.1/class-Cake.I18n.TranslatorRegistry.html