如何在Laravel Blade中大写第一个字母 [英] How to capitalize first letter in Laravel Blade

查看:316
本文介绍了如何在Laravel Blade中大写第一个字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有本地化功能的laravel(5.1)刀片模板引擎.

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

/resources/lang/en/文件夹中有一个语言文件messages.php:

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

return [
    'welcome' => 'welcome',

在我的刀片服务器模板中,使用trans方法调用欢迎消息:

In my blade template the welcome message is called using the trans method:

{{ trans('messages.welcome') }}

在某些情况下,我需要显示相同的消息,但首字母应大写("Welcome").我不想在翻译文件中使用重复的记录.

In some cases I need to show the same message but with first letter capitalized ("Welcome"). I don't want to use duplicate records in the translation file.

我该如何处理?

推荐答案

使用PHP的本机 ucfirst 函数:

Use PHP's native ucfirst function:

{{ ucfirst(trans('messages.welcome')) }}

这篇关于如何在Laravel Blade中大写第一个字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆