The Nuxed Translation component provides tools to internationalize your application.
This package can be installed with Composer.
$ composer require nuxed/translation
use namespace Nuxed\Translation;
use namespace Nuxed\Translation\Loader;
<<__EntryPoint>>
async function main(): Awaitable<void> {
$translator = new Translation\Translator('en');
$translator->addLoader('json', new Loader\JsonLoader());
// "translation/messages.en.json"s content :
// {
// "hello": "Hello {name}"
// }
$translator->addResource('json', 'translation/messages.en.json', 'en');
// "translation/messages.fr.json"s content :
// {
// "hello": "Bonjour {name}"
// }
$translator->addResource('json', 'translation/messages.fr.json', 'fr');
echo await $translator->trans('hello', dict['name' => 'saif']); // Hello saif
echo await $translator->trans('hello', dict['name' => 'saif'], 'fr'); // Bonjour saif
}
For information on reporting security vulnerabilities in Nuxed, see SECURITY.md.
Nuxed is open-sourced software licensed under the MIT-licensed.