Giter Club home page Giter Club logo

laravel5-i18n's Introduction

laravel5-i18n

说明

  • 本扩展包继承于laravel5.8原来多语言翻译函数__($key, $replace = [], $locale = null)的能力

  • 如果不想使用原本的语言文件加载器类,则可以自定义语言包加载器loader,只要在config('jyi18n.translation_loader')中指定自定义的loader即可

使用

  • 安装

    composer -vvv require jy/laravel5-i18n:dev-master
  • 发布资源

    php artisan vendor:publish --provider=Jy\\Laravel5I18n\\Laravel5I18nProvider
  • 调用

// 效果跟调用 __('语言键') 一样
app('jy.i18nhelper')->trans('语言键');
  • 自定义语言包加载器loader

    • 修改config/jyi18n.php中的translation_loader为自定义的类
  • 自定义的类样例

    <?php
    
    namespace App\Libs;
    
    use Jy\Laravel5I18n\LangLoader as Laravel5I18nLangLoader;
    
    class LangLoader extends Laravel5I18nLangLoader
    {
        public function load($locale, $group, $namespace = null){
            
            //缓存数据
            $cache = ['key'=>'value'];
            $lConf = $cache;
    
            if($lConf){
                return $lConf;
            }
    
            return parent::load($locale, $group, $namespace);
        }
    
        public function existsModule(string $moduleName):bool{
            // 判断系统中的$moduleName模块是否存在
            return $ret;
        }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.