[英]Locomotive CMS - Access to translations data
I'm using locomotive CMS and I want to translate some strings. 我正在使用机车CMS,我想翻译一些字符串。 I have the following data in a my tanslations.yml file : 我的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.'
And I can't have access to this data in my 404.liquid page: 而且我无法在404.liquid页面中访问此数据:
---
title: Page not found
published: false
---
{% extends theme %}
{% block 'content' %}
{{ 'general.404.title' | translate }}
{{ 'general.404.subtext_html' | t }}
{% endblock %}
In locomotive/mounter/translation.rb file there is just 2 fields: key and values 在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
Does this mean that we can't structure translations data like this? 这是否意味着我们不能像这样构造翻译数据?
Nope. 不。 From the official page: 从官方页面:
In LocomotiveCMS, you need to have a separate template for each locale. 在LocomotiveCMS中,您需要为每个区域设置单独的模板。 Create a new 404 template for the Japanese localization named app/views/pages/404.ja.liquid and paste in the following contents. 为日语本地化创建一个名为app / views / pages / 404.ja.liquid的新404模板,并粘贴以下内容。
---
title: お探しのページが見つかりません
published: true
---
{% extends 'index' %}
{% block 'main' %}
<p>
申し訳ありません。そのページは存在しません。
</p>
{% endblock %}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.