【问题标题】:problem with @include file in template (laravel)模板中的@include文件问题(laravel)
【发布时间】:2021-12-29 15:26:35
【问题描述】:

我正在尝试使用 dfr lang 将许多文件包含到刀片文件中

@include("frontend.{$config->template}.privacy.Privacy-en")
@include("frontend.{$config->template}.privacy.Privacy-es")
@include("frontend.{$config->template}.privacy.Privacy-de")
.
.
.

我希望根据访问者选择的语言导入其中一个文件

所以我在page.blade.php

中编写了如下代码
@include("frontend.{$config->template}.privacy.{'Privacy-' . LaravelLocalization::getCurrentLocale()}")

错误:

No hint path defined for [frontend.nova.privacy.{'Privacy-'. LaravelLocalization]. (View: C:\xampp\htdocs\templates\frontend\nova\page.blade.php)

任何帮助将不胜感激。

【问题讨论】:

    标签: include laravel-6.2


    【解决方案1】:

    简单的答案是不要这样做。 Laravel 具有对本地化的内置支持,因此无需为每种语言构建不同的页面,然后像您尝试做的那样跳过箍来尝试合并相关的页面。

    阅读the documentation about localisation - 简而言之,设置一个刀片模板(例如称为“privacy.blade.php”)并在其中使用短键,例如:

    {{ __('privacy.introduction') }}
    

    然后在相关语言文件中定义这些键(如 resources/lang/en/privacy.php、/fr/privacy.php 等):

    return [
        'introduction' => 'The following statements set out our privacy information',
    ];
    

    【讨论】:

    • 完成,非常感谢您
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-18
    • 2015-04-16
    • 2022-10-12
    • 2019-05-11
    • 2014-12-10
    • 1970-01-01
    相关资源
    最近更新 更多