定制 dn23rus/laravel-translation-rules 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dn23rus/laravel-translation-rules

最新稳定版本:v1.0.0

Composer 安装命令:

composer require dn23rus/laravel-translation-rules

包简介

README 文档

README

This package gives ability to use translation rules.

Installation

composer require dn23rus/laravel-translation-rules

Configuration

Add service provider to config/app.php

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

Run the command:

php artisan vendor:publish

to publish translation_rules.php

Usage

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 яблок

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-09-26