定制 escuccim/translate 二次开发

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

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

escuccim/translate

Composer 安装命令:

composer require escuccim/translate

包简介

A Laravel translation/localization package

README 文档

README

Latest Version on Packagist Software License Total Downloads

A package to enable localization for Laravel on either a subdomain basis or from the session.

Install

Via Composer

$ composer require escuccim/translate

Register the service provider in /config/app.php 'providers' array:

Escuccim\Translate\TranslateServiceProvider::class,

Register the middleware in /app/Http/Kernel.php in the 'web' array of the $middlewareGroups array:

'web' => [
    ...
     \Escuccim\Translate\Http\Middleware\SetLanguage::class,
],

Make sure that the middleware is after the StartSession middleware if you wish to use session based translation.

Publish the config file with

php artisan vendor:publish

This will place the config file in /config/translate.php.

Usage

The config files has the following keys:

  • use_subdomain - boolean - whether you wish to use subdomain based translation
  • languages - array of languages as follows - 'language' => 'display', where language is the language and display is how you want to display the language in the drop-down menu, if you use it.
  • subdomains - array of languages: 'subdomain' => 'language'. This is used by the middleware to map the subdomain to the language setting
  • date_formats - array of date formats for strftime: 'language' => 'locale', where locale is the format of the dates you wish to use. Note that you must have the date formats installed on your web server for this to work properly. The default locale is en_US_POSIX.

I also include a route: /setlang/{lang} Which sets a session variable to {lang} which will override the subdomain if it is set.

Lastly I include a function to output a Bootstrap drop-down menu which will use the data in the languages key of the config to generate links to set the language in session. This can be accessed with \Escuccim\Translate\TranslateClass::dropDown().

The middleware will first check if subdomain based translation is on, if so it will set the application locale to whatever is specified for the subdomain in the config file. Then if a session variable called 'locale' exists it will override the locale to correspond to the session. This allows you to default to a locale based on subdomain, but then have the user override this if they wish.

Change log

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email skooch@gmail.com instead of using the issue tracker.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固