Constructs and stores instances of translators that can be retrieved by name and locale.
$_cacher
protected A CacheEngine object that is used to remember translator across requests.
$_defaultFormatter
protected string
The name of the default formatter to use for newly created translators from the fallback loader
$_fallbackLoader
protected string
$_loaders
protected 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.
$_useFallback
protected boolean
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.
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.
Sets the CacheEngine instance used to remember translators across requests.
__construct( Aura\Intl\PackageLocator $packages , Aura\Intl\FormatterLocator $formatters , Cake\I18n\TranslatorFactory $factory , string $locale )
Constructor.
$packages
$formatters
$factory
A translator factory to create translator objects for the locale and package.
$locale
_fallbackLoader( string $name , string $locale )
Returns a new translator instance for the given name and locale based of conventions.
$name
$locale
_getFromLoader( string $name , string $locale )
Registers a new package by passing the register loaded function for the package name.
$name
$locale
_getTranslator( string $name , string|null $locale )
Gets a translator from the registry by package for a locale.
$name
$locale
The locale to use; if empty, uses the default locale.
_partialLoader( )
Returns a function that can be used as a loader for the registerLoaderMethod
defaultFormatter( string|null $name null )
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.
$name
optional null get( string $name , string|null $locale null )
Gets a translator from the registry by package for a locale.
$name
$locale
optional null The locale to use; if empty, uses the default locale.
If no translator with that name could be found for the given locale.
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.
$name
$loader
setCacher( Cake\Cache\CacheEngine $cacher )
Sets the CacheEngine instance used to remember translators across requests.
Cake\Cache\CacheEngine
$cacher
setLoaderFallback( string $name , callable $loader )
Set domain fallback for loader.
$name
$loader
useFallback( boolean $enable true )
Set if the default domain fallback is used.
$enable
optional true protected Cake\Cache\CacheEngine
A CacheEngine object that is used to remember translator across requests.
protected string
The name of the default formatter to use for newly created translators from the fallback loader
'default'
protected 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.
[]
© 2005–2017 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/3.4/class-Cake.I18n.TranslatorRegistry.html