简体   繁体   English

Ruby on Rails devise 翻译

[英]Ruby on Rails devise translation

views/devise/sessions/new.html.haml意见/设计/会话/new.html.haml

%h2 
  = t('devise.sessions.link')

devise can't find the translation devise 找不到翻译

<span class="translation_missing" title="translation missing: ru.devise.sessions.link">Link</span> 

but

ru:
  devise:
    sessions:
      link: 'Войти'

is present in config/locales/devise.ru.yml存在于 config/locales/devise.ru.yml

Rails merges the parsed yaml files correctly but, when a key is used twice within the same translation file, one of them will be replaced by the other, the same way it would when adding an existing key value pair to a manually created hash. Rails 正确地合并了解析的 yaml 文件,但是,当一个键在同一个翻译文件中使用两次时,其中一个将被另一个替换,就像将现有键值对添加到手动创建的 hash 时一样。

example yaml file:示例 yaml 文件:

----
:foo: bar
:foo: foo

example code use:示例代码使用:

require 'rubygems'
require 'yaml'
YAML::load("--- \n:foo: :bar\n:foo: :foo\n")

output: output:

=> {:foo=>:foo} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM