Skip to content

Commit a0845f6

Browse files
committed
docs: update documentation of i18n support
1 parent c8dce0e commit a0845f6

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

README.md

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -824,33 +824,23 @@ Whenever an exception is caught by `Application::handle()`, it will show a beaut
824824

825825
**adhocore/cli** also supports internationalisation. This is particularly useful if you are not very comfortable with English or if you are creating a framework or CLI application that could be used by people from a variety of backgrounds.
826826

827-
By default, all texts generated by our system are in English. But you can easily change them at any time
827+
By default, all the texts generated by our system are in English. But you can easily modify them by defining your translations as follows
828828

829829
```php
830-
\Ahc\Translations\Translator::$locale = 'fr';
830+
\Ahc\Application::addLocale('fr', [
831+
'Only last argument can be variadic' => 'Seul le dernier argument peut être variadique',
832+
], true);
831833
```
832834

833-
The system currently supports 5 fully translated languages:
834-
835-
* English: `en`
836-
* French: `fr`
837-
* Spanish: `es`
838-
* German: `de`
839-
* Russian: `ru`
840-
841-
If the language you want to use is not supported natively, you can create your own translation file from the main translation file. Simply copy the entire contents of the file `vendor/adhocore/cli/src/Translations/en.php` and translate all the translation values into the desired language.
842-
843-
After that, you will need to enter the path to the folder where your translation files are stored.
844-
For example, if you have made Chinese (`ch`) and Arabic (`ar`) translations, and they are respectively in the `APP_PATH/translations/ch.php` and `APP_PATH/translations/ar.php` files, you can configure the translator as follows
835+
You can also change the default English text to make the description more explicit if you wish.
845836

846837
```php
847-
\Ahc\Translations\Translator::$translations_dir = APP_PATH . '/translations';
848-
\Ahc\Translations\Translator::$locale = 'ch'; // or 'ar'
838+
\Ahc\Application::addLocale('en', [
839+
'Show help' => 'Shows helpful information about a command',
840+
]);
849841
```
850842

851-
In the same way, you can override the built-in translations, just create your own file `en.php` or `fr.php`, etc... and indicate the folder in which it is located
852-
853-
You don't have to translate all the translation keys. If a translation key does not exist in your implementation, the default value will be used. This allows you to translate only the elements you consider important (for example, exception messages do not necessarily need to be translated).
843+
vous pouvez trouver toutes les clés de traduction supportées par le paquet dans cette gist : https://gist.github.com/dimtrovich/1597c16d5c74334e68eef15a4e7ba3fd
854844

855845
## Autocompletion
856846

0 commit comments

Comments
 (0)