Constructs and stores instances of translators that can be retrieved by name and locale.
(\Psr\SimpleCache\CacheInterface&\Cake\Cache\CacheEngineInterface)|null
A CacheEngine object that is used to remember translator across requests.
string
The name of the default formatter to use for newly created translators from the fallback loader
string
Fallback 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.
bool
Use fallback-domain for translation loaders.
\Aura\Intl\TranslatorFactory
A translator factory.
\Aura\Intl\FormatterLocator
A formatter locator.
string
The current locale code.
\Aura\Intl\PackageLocator
A package locator.
array
A 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\TranslatorInterface
A 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\TranslatorInterface
A translator object.
_partialLoader()
Returns a function that can be used as a loader for the registerLoaderMethod
\Closure
defaultFormatter(?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.
string
The 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|null
A translator object.
Aura\Intl\Exception
getFactory()
The TranslatorFactory object
\Aura\Intl\TranslatorFactory
getFormatters()
An object of type FormatterLocator
\Aura\Intl\FormatterLocator
getLocale()
Returns the default locale code.
string
getPackages()
An object of type PackageLocator
\Aura\Intl\PackageLocator
registerLoader(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
callable
loader
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)|null
The name of the default formatter to use for newly created translators from the fallback loader
string
Fallback loader name
string
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.
callable[]
Use fallback-domain for translation loaders.
bool
A translator factory.
\Aura\Intl\TranslatorFactory
A formatter locator.
\Aura\Intl\FormatterLocator
The current locale code.
string
A package locator.
\Aura\Intl\PackageLocator
A 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