php - Laravel:子文件夹中的 lang 文件

标签 php laravel laravel-5 localization

我想“多本地化”我的 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 both front folder and front.php file).

关于php - Laravel:子文件夹中的 lang 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45657634/

相关文章:

php - 排队的 Laravel 作业全部同时触发,并且不会显示在作业表中

php - 请求 Blade View 模板中使用的所有变量的列表

php - 如何对模型执行删除操作?

php - 按列值从大表中删除重复行

php - 设置一个配置 PHP 类来保留项目设置是否正确?

mysql - 选择所有具有精确字段的

php - 如何在 laravel 5.2 zizaco entrust :migration class name validation? 中修复

php - Laravel-5 每个日志表的独立模型

php - 我们应该在 Amazon MWS PHP SDK 的 APPLICATION_NAME 和 APPLICATION_VERSION 字段中输入什么?

php - php代码中的sql查询