【问题标题】:Is there a way to translate the title in the configuration section of an octobercms page有没有办法在 octobercms 页面的配置部分翻译标题
【发布时间】:2017-11-02 20:46:39
【问题描述】:

我安装了rainlab翻译插件,它在twigg翻译中运行良好

{{ "text to translate"|_ }}

另外,我知道我们可以很容易地在插件中创建 lang 文件夹,我们可以这样:

'name' => 'Traductions', 

我也在页面配置中以这种方式翻译了我的网址:

[viewBag]
localeUrl[en] = "/clinics/slug"

但是是否可以为标题做类似的事情? 我需要在页面的php/配置部分翻译页面标题。

谢谢

【问题讨论】:

    标签: php laravel localization translation octobercms


    【解决方案1】:

    我猜你可以利用代码部分

    并把这段代码

    url = "/blog"
    layout = "default"
    ==
    <?
    function onEnd() {
        $this->page->title = <<Your Translated Title>>;
    } 
    ?>
    ==
    <h3>Html Here</h3>
    

    (假设您使用的是rainlab翻译插件)要翻译消息,您可以使用

    use RainLab\Translate\Models\Message;
    

    然后

    $this->page->title = Message::trans($string, $params);
    

    希望对你有帮助。

    【讨论】:

    • 谢谢!有用。重要的是要提到它必须在“onEnd()”函数中才能工作。
    【解决方案2】:

    如果您使用正确的工具正确地做到这一点,使用 10 月的插件开发可翻译网站不会花费太多时间。

    使用翻译插件,可以将语言指定为 URL 的一部分,您将能够轻松使用 Twig 过滤器。

    检查这个: http://octobercms.com/blog/post/building-responsive-multi-language-website-blog-and-static-pages

    【讨论】:

      猜你喜欢
      • 2022-01-13
      • 1970-01-01
      • 2020-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多