Ruby on Rails设计翻译(Ruby on Rails devise translation)
意见/设计/会话/ new.html.haml
%h2 = t('devise.sessions.link')设计无法找到翻译
<span class="translation_missing" title="translation missing: ru.devise.sessions.link">Link</span>但
ru: devise: sessions: link: 'Войти'存在于config / locales / devise.ru.yml中
views/devise/sessions/new.html.haml
%h2 = t('devise.sessions.link')devise can't find the translation
<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
最满意答案
Rails正确合并解析后的yaml文件,但是当在同一个转换文件中使用两次密钥时,其中一个将被另一个替换,就像将现有密钥值对添加到手动创建的哈希时一样。
示例yaml文件:
---- :foo: bar :foo: foo示例代码使用:
require 'rubygems' require 'yaml' YAML::load("--- \n:foo: :bar\n:foo: :foo\n")输出:
=> {:foo=>:foo}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.
example yaml file:
---- :foo: bar :foo: fooexample code use:
require 'rubygems' require 'yaml' YAML::load("--- \n:foo: :bar\n:foo: :foo\n")output:
=> {:foo=>:foo}更多推荐
发布评论