|
| 1 | +<p align="center"><img src="https://avatars3.githubusercontent.com/u/45311177?s=200&v=4"></p> |
| 2 | + |
| 3 | +<p align="center"> |
| 4 | +<a href="https://travis-ci.org/nuxed/translation"><img src="https://travis-ci.org/nuxed/translation.svg" alt="Build Status"></a> |
| 5 | +<a href="https://packagist.org/packages/nuxed/translation"><img src="https://poser.pugx.org/nuxed/translation/d/total.svg" alt="Total Downloads"></a> |
| 6 | +<a href="https://packagist.org/packages/nuxed/translation"><img src="https://poser.pugx.org/nuxed/translation/v/stable.svg" alt="Latest Stable Version"></a> |
| 7 | +<a href="https://packagist.org/packages/nuxed/translation"><img src="https://poser.pugx.org/nuxed/translation/license.svg" alt="License"></a> |
| 8 | +</p> |
| 9 | + |
| 10 | +# Nuxed Translation |
| 11 | + |
| 12 | +The Nuxed Translation component provides tools to internationalize your application. |
| 13 | + |
| 14 | +### Installation |
| 15 | + |
| 16 | +This package can be installed with [Composer](https://getcomposer.org). |
| 17 | + |
| 18 | +```console |
| 19 | +$ composer require nuxed/translation |
| 20 | +``` |
| 21 | + |
| 22 | +### Example |
| 23 | + |
| 24 | +```hack |
| 25 | +use namespace Nuxed\Translation; |
| 26 | +use namespace Nuxed\Translation\Loader; |
| 27 | +
|
| 28 | +<<__EntryPoint>> |
| 29 | +async function main(): Awaitable<void> { |
| 30 | + $translator = new Translation\Translator('en'); |
| 31 | + $translator->addLoader('json', new Loader\JsonLoader()); |
| 32 | +
|
| 33 | + // "translation/messages.en.json"s content : |
| 34 | + // { |
| 35 | + // "hello": "Hello {name}" |
| 36 | + // } |
| 37 | + $translator->addResource('json', 'translation/messages.en.json', 'en'); |
| 38 | +
|
| 39 | + // "translation/messages.fr.json"s content : |
| 40 | + // { |
| 41 | + // "hello": "Bonjour {name}" |
| 42 | + // } |
| 43 | + $translator->addResource('json', 'translation/messages.fr.json', 'fr'); |
| 44 | +
|
| 45 | + echo await $translator->trans('hello', dict['name' => 'saif']); // Hello saif |
| 46 | +
|
| 47 | + echo await $translator->trans('hello', dict['name' => 'saif'], 'fr'); // Bonjour saif |
| 48 | +} |
| 49 | +``` |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +### Security |
| 54 | + |
| 55 | +For information on reporting security vulnerabilities in Nuxed, see [SECURITY.md](SECURITY.md). |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +### License |
| 60 | + |
| 61 | +Nuxed is open-sourced software licensed under the MIT-licensed. |
0 commit comments