我在application.rb中将默认语言环境设置为:es
:
config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = :es
我的es.yml
文件看起来像这样:
es:
hello:
world: "Hola mundo"
activerecord:
attributes:
post:
title: "Titulo"
errors:
models:
post:
attributes:
title:
blank: "Hey el %{attribute} está en blanco!"
too_short: "%{count} carácteres mínimos"
text:
blank: "Hey el %{attribute} está en blanco!"
too_short: "%{count} carácteres mínimos"
我正在尝试使这些嵌套翻译键在<%= t :'hello.world' %>
这样的视图中工作,使用此配置我收到以下错误:
can not load translations from /home/edd/Programming/ruby/rails/blog/config/locales/en.yml: #<Psych::SyntaxError: (/home/edd/Programming/ruby/rails/blog/config/locales/en.yml): found character that cannot start any token while scanning for the next token at line 23 column 1>
此错误提到en.yml
,其结构如下:
en:
hello:
world: "Hello world"
activerecord:
attributes:
post:
title: "Title"
...
如果我删除嵌套部分,它开始工作,t帮助程序开始工作:
en:
world: "Hello world"
这里可能发生什么?提前感谢您的意见。
答案 0 :(得分:2)
我们需要确保有空间解决这个问题。
例如: -
en:
articles:
index:
heading_list: 'Gurudath Articles List In English'
description: 'Gurudath Articles Description In English'
答案 1 :(得分:0)
检查第23行是否有任何奇怪的字符,例如一系列标签中的空格等。
如果是这样,请移除并确保均匀性。