A generic translations package factory that will load translations files based on the file extension and the package name.
This class is a callable, so it can be used as a package loader argument.
string
The extension name.
string
The locale to load for the given package.
string
The package (domain) name.
Creates a translation file loader. The file to be loaded corresponds to the following rules:
Loads the translation file and parses it. Returns an instance of a translations package containing the messages loaded from the file.
Returns the folders where the file should be looked for according to the locale and package name.
__construct(string $name, string $locale, string $extension)
Creates a translation file loader. The file to be loaded corresponds to the following rules:
Locale
directory, a fallback will be used if the folder is not found.Load and parse resources/locales/fr/validation.po
$loader = new MessagesFileLoader('validation', 'fr_FR', 'po'); $package = $loader();
Load and parse resources/locales/fr_FR/validation.mo
$loader = new MessagesFileLoader('validation', 'fr_FR', 'mo'); $package = $loader();
Load the plugins/MyPlugin/resources/locales/fr/my_plugin.po file:
$loader = new MessagesFileLoader('my_plugin', 'fr_FR', 'mo'); $package = $loader();
string
$name The name (domain) of the translations package.
string
$locale The locale to load, this will be mapped to a folder in the system.
string
$extension optional The file extension to use. This will also be mapped to a messages parser class.
__invoke()
Loads the translation file and parses it. Returns an instance of a translations package containing the messages loaded from the file.
\Aura\Intl\Package|false
RuntimeException
translationsFolders()
Returns the folders where the file should be looked for according to the locale and package name.
string[]
The list of folders where the translation file should be looked for
The extension name.
string
The locale to load for the given package.
string
The package (domain) name.
string
© 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.MessagesFileLoader.html