Constructs and stores instances of translators that can be retrieved by name and locale.
string
'_fallback'
Fallback loader name.
Psr\SimpleCache\CacheInterfaceCake\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
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.
bool
Use fallback-domain for translation loaders.
Cake\I18n\FormatterLocator
A formatter locator.
string
The current locale code.
Cake\I18n\PackageLocator
A 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\Translator
createInstance(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\Translator
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 optional The name of the formatter to use.
string
get(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|null
Cake\I18n\Exception\I18nException
getFormatters(): Cake\I18n\FormatterLocator
An object of type FormatterLocator
Cake\I18n\FormatterLocator
getLocale(): string
Returns the default locale code.
string
getPackages(): Cake\I18n\PackageLocator
Returns the translator packages
Cake\I18n\PackageLocator
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
void
setCacher(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.
void
setFallbackPackage(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\Package
setLoaderFallback(string $name, callable $loader): callable
Set domain fallback for loader.
string
$name The name of the loader domain
callable
$loader invokable loader
callable
setLocale(string $locale): void
Sets the default locale code.
string
$locale The new locale code.
void
useFallback(bool $enable = true): void
Set if the default domain fallback is used.
bool
$enable optional flag to enable or disable fallback
void
A CacheEngine object that is used to remember translator across requests.
Psr\SimpleCache\CacheInterfaceCake\Cache\CacheEngineInterface)|null
The name of the default formatter to use for newly created translators from the fallback loader
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.
array<callable>
Use fallback-domain for translation loaders.
bool
A formatter locator.
Cake\I18n\FormatterLocator
The current locale code.
string
A package locator.
Cake\I18n\PackageLocator
A 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