How to capitalize first letter in Laravel Blade

后端 未结 4 823
無奈伤痛
無奈伤痛 2021-02-06 21:28

I\'m using laravel (5.1) blade template engine with the localization feature.

There is a language file messages.php within the /resources/lang/en/

4条回答
  •  既然无缘
    2021-02-06 21:50

    Add a blade directive to the app/Providers/AppServiceProvider's boot() function:

    public function boot() {
    
        Blade::directive('lang_u', function ($s) {
            return "";
        });
    
    }
    

    This way you can use the following in your blade files:

    @lang_u('messages.welcome')
    

    which outputs: Welcome

     

    You're @lang_u('messages.welcome') :)

提交回复
热议问题