Constructs and stores instances of translators that can be retrieved by name and locale.
string '_fallback'
Fallback loader name.
Psr\SimpleCache\CacheInterfaceCake\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
array<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.
Cake\I18n\FormatterLocatorA formatter locator.
stringThe current locale code.
Cake\I18n\PackageLocatorA package locator.
array<string, array<string,Cake\I18n\Translator>>A registry to retain translator objects.
Constructor.
Gets a translator from the registry by package for a locale.
Create translator instance.
Sets the name of the default messages formatter to use for future translator instances.
Gets a translator from the registry by package for a locale.
An object of type FormatterLocator
Returns the default locale code.
Returns the translator packages
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.
Sets the CacheEngine instance used to remember translators across requests.
Set fallback domain for package.
Set domain fallback for loader.
Sets the default locale code.
Set if the default domain fallback is used.
__construct(Cake\I18n\PackageLocator $packages, Cake\I18n\FormatterLocator $formatters, string $locale)
Constructor.
Cake\I18n\PackageLocator $packages The package locator.
Cake\I18n\FormatterLocator $formatters The formatter locator.
string $locale The default locale code to use.
_getTranslator(string $name, string $locale): Cake\I18n\Translator
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.
Cake\I18n\TranslatorcreateInstance(string $name, string $locale): Cake\I18n\Translator
Create translator instance.
string $name The translator package to retrieve.
string $locale The locale to use; if empty, uses the default locale.
Cake\I18n\TranslatordefaultFormatter(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 optional The name of the formatter to use.
stringget(string $name, string|null $locale = null): Cake\I18n\Translator|null
Gets a translator from the registry by package for a locale.
string $name The translator package to retrieve.
string|null $locale optional The locale to use; if empty, uses the default locale.
Cake\I18n\Translator|nullCake\I18n\Exception\I18nExceptiongetFormatters(): Cake\I18n\FormatterLocator
An object of type FormatterLocator
Cake\I18n\FormatterLocatorgetLocale(): string
Returns the default locale code.
stringgetPackages(): Cake\I18n\PackageLocator
Returns the translator packages
Cake\I18n\PackageLocatorregisterLoader(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
voidsetCacher(Psr\SimpleCache\CacheInterfaceCake\Cache\CacheEngineInterface $cacher): void
Sets the CacheEngine instance used to remember translators across requests.
Psr\SimpleCache\CacheInterfaceCake\Cache\CacheEngineInterface $cacher The cacher instance.
voidsetFallbackPackage(string $name, Cake\I18n\Package $package): Cake\I18n\Package
Set fallback domain for package.
string $name The name of the package.
Cake\I18n\Package $package Package instance
Cake\I18n\PackagesetLoaderFallback(string $name, callable $loader): callable
Set domain fallback for loader.
string $name The name of the loader domain
callable $loader invokable loader
callablesetLocale(string $locale): void
Sets the default locale code.
string $locale The new locale code.
voiduseFallback(bool $enable = true): void
Set if the default domain fallback is used.
bool $enable optional flag to enable or disable fallback
voidA CacheEngine object that is used to remember translator across requests.
Psr\SimpleCache\CacheInterfaceCake\Cache\CacheEngineInterface)|nullThe name of the default formatter to use for newly created translators from the fallback loader
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.
array<callable>Use fallback-domain for translation loaders.
boolA formatter locator.
Cake\I18n\FormatterLocatorThe current locale code.
stringA package locator.
Cake\I18n\PackageLocatorA registry to retain translator objects.
array<string, array<string,Cake\I18n\Translator>>
© 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.4/class-Cake.I18n.TranslatorRegistry.html