2017 © Pedro Peláez
 

library laravel-translation-rules

image

dn23rus/laravel-translation-rules

  • Saturday, September 26, 2015
  • by b.dmitry
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Overview

This package gives ability to use translation rules., (*1)

Installation

composer require dn23rus/laravel-translation-rules, (*2)

Configuration

Add service provider to config/app.php, (*3)

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

Run the command:, (*4)

php artisan vendor:publish, (*5)

to publish translation_rules.php, (*6)

Usage

Now you can add rule to resources/lang/translation_rules.php, for example rule for Russian language:, (*7)

    '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:, (*8)

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

So, (*9)

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

The Versions

26/09 2015

dev-master

9999999-dev

  Sources   Download

The Requires

 

by Dmitry Buryak

26/09 2015

v1.0.0

1.0.0.0

  Sources   Download

The Requires

 

by Dmitry Buryak