PHP code example of dn23rus / laravel-translation-rules

1. Go to this page and download the library: Download dn23rus/laravel-translation-rules library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dn23rus / laravel-translation-rules example snippets


    'providers' => [
        //...
        Dmbur\TranslationRule\TranslationRuleServiceProvider::class
    ]

    '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);
    },

    'apple' => '{0}яблоко|{1}яблока|{2}яблок'

echo 5 . ' ' . trans_rule('app.apple', 5) // will produce 5 яблок