dtrgqjcd877528 2019-08-15 06:58
浏览 27

如何将数据从DB调用到语言文件,然后将其调用到刀片文件

i'm trying to call the data i need to the lang files then call it back in the blade file using the {{trans('')}}

tried to add the path into the lang file and call it back but it wont work

this is the lang file

'menu_1'=> '$category[\'languages\'][0][\'title\']',
'menu_2'=> '{{$category[\'languages\'][1][\'title\']}}'

and this is the blade file

 {{trans('main.menu_1')}}

i need it to show the menu_1 name in the blade file but instead it's showing

$category[\'languages\'][0][\'title\']
  • 写回答

1条回答 默认 最新

  • douchujian8124 2019-08-15 09:12
    关注

    Your Translation Text ist a String and is not interpreted as PHP. A way to get your code working would be to use {{array_get($category,trans('main.menu_1')}} and store a the array path as dot notation in your language file like 'menu_1'=>'languages.0.title'

    See https://laravel.com/docs/5.5/helpers#method-array-get

    评论

报告相同问题?

悬赏问题

  • ¥15 vscode的问题提问
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM