1

我正在使用机车 CMS,我想翻译一些字符串。我的tanslations.yml文件中有以下数据:

  general: 
    404: 
      title: 
        en: "404 Page Not Found"
        fr: "404 - Page non trouvée"
        de: "404 Seite nicht gefunden"
        es: "404 Página no encontrada"
        pt-BR: "404 Página não encontrada"

      subtext_html: 
        en: 'The page you requested does not exist. Click <a href=\"/collections/all\">here</a> to continue shopping.'
        fr: "Cette page n'est pas disponible. <a href= '/collections/all'>Retourner au magasin</a>"
        de: 'Die von Ihnen angeforderte Seite existiert nicht. Klicken Sie <a href=\"/collections/all\">hier</a>, um den Einkauf fortzusetzen.'
        es: 'La página que ha solicitado no existe. Haga clic <a href=\"/collections/all\">aquí</a> para continuar la compra.'
        pt-BR: 'A página que você solicitou não existe. Clique <a href=\"/collections/all\">aqui</a> para voltar às compras.'

而且我无法在我的404.liquid页面中访问这些数据:

---
title: Page not found
published: false
---
{% extends theme %}
    {% block 'content' %}
        {{ 'general.404.title' | translate }}
        {{ 'general.404.subtext_html' | t }}
    {% endblock %}

locomotive/mounter/translation.rb文件中只有 2 个字段:键和值

module Locomotive
  module Mounter
    module Models

      class Translation < Base

        ## fields ##
        field :key
        field :values

        ## methods ##

        def get(locale)
          self.values[locale.to_s]
        end

        def to_params
          { key: self.key, values: self.values }
        end

        def to_s
          "Translation #{self.key} (#{self.values.keys.join(', ')})"
        end

      end
    end
  end
end

这是否意味着我们不能像这样构建翻译数据?

4

1 回答 1

0

没有。从官方页面:

在 LocomotiveCMS 中,您需要为每个区域设置一个单独的模板。为名为 app/views/pages/404.ja.liquid 的日语本地化创建一个新的 404 模板并粘贴以下内容。

---
title: お探しのページが見つかりません
published: true
---
{% extends 'index' %}

{% block 'main' %}
  <p>
    申し訳ありません。そのページは存在しません。
  </p>
{% endblock %}

你可以在这里查看整个教程。

于 2016-05-25T00:16:31.240 回答