我想“多本地化”我的 Laravel 项目。
我的目录结构是这样的:
lang
- en
- front
- contact.php
-footer.php
我的页脚是这样的:
{{ link_to('/', trans('footer.frontpage'))}}
它工作得很好,但是当我想本地化其他 Blade 页面时,例如像这样的 contact us
页面:
@lang('front.contact.name')
或者这个:
{{ __('front.contact.name') }}
或者这个:
{{ trans('front.contact.name') }}
我只回到了页面:
front.contact.name
有什么问题?
最佳答案
只需使用/
作为目录分隔符。
{{ trans('front/contact.name') }}
In Blade both "
/
" and ".
" function (while the latter is recommended).But for
Lang
the ".
" is unintentionally reserved for file's content (array and any number of child-array), so that we can have both a folder and file with the same name (like bothfront
folder andfront.php
file).
关于php - Laravel:子文件夹中的 lang 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45657634/