简体   繁体   English

在 Laravel Blade sing json 文件上翻译 DB 变量

[英]Translating a DB variable on a Laravel Blade sing json file

I usually do translate from the blade like this, not from the database我通常像这样从刀片翻译,而不是从数据库翻译

{{ ___('texts.welcome')}}

And JSON like this.和 JSON 这样。

{
  "welcome": "Welcome"
}

That works for me这对我行得通

But I am trying to translate the DB variable on Laravel Blade using a JSON file like I usually do I found an answer in StackOverflow but there is no answer to how to write variables in a JSON file但是我正在尝试使用 JSON 文件在 Laravel Blade 上翻译 DB 变量,就像我通常做的那样 我在 StackOverflow 中找到了答案但是没有关于如何在 JSON 文件中写入变量的答案
this answer:- Translating a DB variable on a laravel Blade这个答案:- 在 laravel Blade 上翻译一个 DB 变量

{ ___('texts.' . $value->name) }}

I am expecting an answer on how to write variable values in my JSON file.我期待关于如何在我的 JSON 文件中写入变量值的答案。

Try the following:尝试以下操作:

{
  "welcome": "Welcome, {{ $username }}"
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM