自定义语言未在Laravel 8中正确添加 [英] Custom language not added properly in Laravel 8

查看:71
本文介绍了自定义语言未在Laravel 8中正确添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中使用Laravel 8.但是,我想添加自己的语言进行验证,因此我使用了 laravel-lang 并放置了 resources/lang/目录中的 fa 文件夹.

I'm using Laravel 8 for my project. However, I wanted to add my own language for validation, so I used laravel-lang and placed the fa folder inside the resources/lang/ directory.

然后我将它们添加到 config/app.php :

'locale' => 'fa',
'fallback_locale' => 'fa',
'faker_locale' => 'fa_IR',

我还重新运行了 php artisan serve 来测试它是否有效,但是问题是,它不起作用,并且仍然显示用于登录/注册控制器验证的英文消息.

And I also re-run the php artisan serve to test if it works or not, but the problem is, it does not work and still shows the English messages for Login/Register Controller validation.

那么这里出了什么问题?如何正确添加我的语言?

So what is going wrong here? How can I add my language properly?

推荐答案

要使用翻译,您应该使用正确的语法来翻译变量或句子:

In order to use translation you should use proper syntax to translate your variables or your sentences:

{{_('your_variable')}}

如果使用此语法并且问题仍然存在,请检查html 语言元标记 lang 属性:

If you use this syntax and the problem exist yet, check your html language meta tag or lang attribute:

应为< html lang ="fa"> .

这篇关于自定义语言未在Laravel 8中正确添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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