定制 m1sh0u/laravel-polyglot-translator 二次开发

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

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

m1sh0u/laravel-polyglot-translator

Composer 安装命令:

composer require m1sh0u/laravel-polyglot-translator

包简介

Polyglot.php translator for Laravel

README 文档

README

Latest Version on Packagist Software License Code Quality Total Downloads

Installing this package will enable using Polyglot.php to translate phrases through a Laravel application.

When installed, the trans and trans_choice will use the Polyglot.php library to translate the given phrases:

trans('Hello, %{placeholder}', ['placeholder' => 'World']);
trans('1 vote %{period} |||| %{smart_count} votes %{period}', ['smart_count' => 4, 'period' => 'today'])

trans_choice('1 vote %{period} |||| %{smart_count} votes %{period}', 4, ['period' => 'today']);

Installation

You can install the package via composer:

composer require m1sh0u/laravel-polyglot-translator

In config/app.php (Laravel) or bootstrap/app.php (Lumen) you should replace Laravel's translation service provider,

Illuminate\Translation\TranslationServiceProvider::class,

by the one included in this package:

LaravelPolyglot\Providers\TranslationServiceProvider

Optionally you could publish the config file using the command:

php artisan vendor:publish --provider="LaravelPolyglot\Providers\TranslationServiceProvider" --tag="config"

This is the contents of the published config file:

return [
    // @see https://github.com/M1Sh0u/polyglot.php for the meaning of each polyglot configuration parameter
    'polyglot' => [
        
        'allowMissing' => true,
        'delimiter' => '||||',
        'interpolation' => [
            'prefix' => '%{',
            'suffix' => '}'
        ],
        'pluralRules' => [],

        // Set a callback function to be called whenever a missing key is found.
        // It could be useful if you need to store the missing keys into the database or to do something else.
        // Please note that the return of this callback will be the actual string returned by the translator. @see https://github.com/M1Sh0u/polyglot.php
        'onMissingKey' => null,
        'onMissingKeyEnvs' => ['local', 'staging']
    ]
];

Note: publishing assets doesn't work out of the box in Lumen. Instead you have to copy the files from the repo.

Usage

For more information about Polyglot.php' capabilities please follow its documentation

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固