为了账号安全,请及时绑定邮箱和手机立即绑定

TranslationServiceProvider.php

标签:
PHP

<?php

 

namespace Illuminate\Translation;

 

use Illuminate\Support\ServiceProvider;

// namesapce

class TranslationServiceProvider extends ServiceProvider

{// son and father

    /**

     * Indicates if loading of the provider is deferred.

     *

     * @var bool

     */

    protected $defer = true;// wether provider indicates

 

    /**

     * Register the service provider.

     *

     * @return void

     */

    public function register()

    {// register the service provider

        $this->registerLoader();//set the register Loader

 

        $this->app->singleton('translator', function ($app) {

            $loader = $app['translation.loader'];// a singleton function

 

            // When registering the translator component, we'll need to set the default

            // locale as well as the fallback locale. So, we'll grab the application

            // configuration so we can easily get both of these values from there.

            $locale = $app['config']['app.locale'];

           // When registering the translator component, we'll need to set the default

           // locale as well as the fallback locale. so, we'll grab the application

           // configuration so we can easily get both of these values from there.

 

            $trans = new Translator($loader, $locale);//get a instance

 

            $trans->setFallback($app['config']['app.fallback_locale']);// set Fall back

 

            return $trans;// return this trans

        });

    }

 

    /**

     * Register the translation line loader.

     *

     * @return void

     */

    protected function registerLoader()

    {

        $this->app->singleton('translation.loader', function ($app) {

            return new FileLoader($app['files'], $app['path.lang']);

        });// use a big wrap function

    }// register loader

 

    /**

     * Get the services provided by the provider.

     *

     * @return array

     */

    public function provides()

    {

        return ['translator', 'translation.loader'];

    }// a static return

}


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

举报

0/150
提交
取消