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/ folder:

return [
    'welcome' => 'welcome',

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

{{ trans('messages.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.

How can I approach this?

推荐答案

使用PHP的原生ucfirst函数:

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

Laravel相关问答推荐

Nuxt 3获取多部分表单数据上传不起作用

哈希:check()不返回预期结果Laravel 10

在postgres/mysqlс中,我可以定义基于json字段的唯一索引吗?

工厂多对多数据透视表属性

spatie 包 laravel-tags 在迁移中没有 down() 函数是有原因的吗

未定义防护 [api] 的授权驱动程序 [api]

处理程序类中的错误 - Laravel

Eloquent: hasNot 带参数

localhost 和stream_socket_enable_crypto():SSL 操作失败,代码为 1

有条件的Eager加载

Laravel Blade 没有额外的空格?

PHP 5.5,什么情况下PHP会导致很高的committed memory

在 Laravel 中将 Public 添加到assets资源路径

在 laravel 6.0 中未定义命令ui

将图标添加到 Laravelcollective 提交按钮

升级到 laravel 5.3 后错误 datetime format: 1292 Incorrect datetime value: '0000-00-00 00:00:00'

无法声明类 Controller,因为该名称已在使用中

Laravel 5 - 判断日期是否是今天

Laravel 5 - 从控制器级别的所有请求对象中删除参数

如何在 Laravel 5 中验证 RESTful API?