nuxed/translation

Nuxed Translation

Installs: 26

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 0

Language:Hack

v2.0.1 2020-11-23 05:46 UTC

This package is auto-updated.

Last update: 2024-10-23 15:37:37 UTC


README

Coding standards status Static analysis status Unit tests status Total Downloads Latest Stable Version License

Nuxed Translation

The Nuxed Translation component provides tools to internationalize your application.

Installation

This package can be installed with Composer.

$ composer require nuxed/translation

Example

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
}

Security

For information on reporting security vulnerabilities in Nuxed, see SECURITY.md.

License

Nuxed is open-sourced software licensed under the MIT-licensed.