Package Data | |
---|---|
Maintainer Username: | b.dmitry |
Maintainer Contact: | boss23rus@gmail.com (Dmitry Buryak) |
Package Create Date: | 2015-09-26 |
Package Last Update: | 2015-09-26 |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2024-11-22 03:14:06 |
Package Statistics | |
---|---|
Total Downloads: | 11 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
This package gives ability to use translation rules.
composer require dn23rus/laravel-translation-rules
Add service provider to config/app.php
'providers' => [
//...
Dmbur\TranslationRule\TranslationRuleServiceProvider::class
]
Run the command:
php artisan vendor:publish
to publish translation_rules.php
Now you can add rule to resources/lang/translation_rules.php
, for example rule for Russian language:
'ru' => function ($n) {
return ($n % 10 == 1 && $n % 100 != 11) ? 0 :
($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
},
And example of message in file resource/lang/ru/app.php
:
'apple' => '{0}яблоко|{1}яблока|{2}яблок'
So
echo 5 . ' ' . trans_rule('app.apple', 5) // will produce 5 яблок