定制 plokko/locale-manager 二次开发

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

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

plokko/locale-manager

Composer 安装命令:

composer require plokko/locale-manager

包简介

Laravel persistent locale and Javascript/Vue.js translation support

README 文档

README

Generates and manage Javascript Laravel localization and current locale

Installation

Install with composer

composer require plokko/locale-manager

Laravel >=5.5 should auto discover and register the required services.

If you have laravel <5.5 you need to manually register the provider in your /config/app.php

<?php
//...
   'providers' => [
                 //...
                 //-- Add locale manager --//
                 Plokko\LocaleManager\LocaleManagerServiceProvider::class,
                 //...
   ],
//...

To edit configuration parameter publish it with php artisan vendor:publish --provider="Plokko\LocaleManager\LocaleManagerServiceProvider" --tag="config" then edit your config\locale-manager.php configuration file.

Persistent locale

If you want to automatically set the Laravel locale to the user (browser preferred) locale or let the user set a locale (via cookie) you can add the PersistentLocale middleware included in this package: edit your /App/Http/Kernel.php file and add the \Plokko\LocaleManager\PersistentLocale middleware

<?php
   //...
    protected $middlewareGroups = [
        'web' => [
            //...
            //add this line below
            \Plokko\LocaleManager\Middleware\PersistentLocale::class,
            //...
        ],
//...

Javascript initialization

Include the Javascript code in your main app.js file like below:

/*** Import translation plugin ***/
import Localization from '../../vendor/plokko/locale-manager/assets/js/Localization';

// Make it globally accessible from the page 
// NOTE: variable name MUST be the same js_class 
window.Localization = new Localization();

// Optional: add global functions
window.trans = function(key,replace){return window.Localization.trans(key,replace);};
window.trans_choice = function(key,number,replace){return window.Localization.trans_choice(key,number,replace);};

// Optional: Vue mixin to make it globally available
Vue.mixin({
    methods:{
        trans: window.trans ,
        trans_choice: window.trans_choice ,
    },
    filters:{
        trans:(s) => window.trans(s),
    }
});

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2017-11-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固