如何在Rails 3中使用I18n后备功能 [英] How to use the I18n fallback features in Rails 3
本文介绍了如何在Rails 3中使用I18n后备功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到翻译缺失"的提示;来自Rails 3的错误消息:
I am getting an "translation missing" error message from Rails 3:
activerecord:
notices:
messages:
success:
create: "Something was created"
models:
user:
success:
create: "Thanks for registration"
I18n.t("activerecord.notices.models.user.success.create")
# => "Thanks for registration"
I18n.t("activerecord.notices.models.book.success.create")
# => "translation missing: de, activerecord, notices, models, book, success, create"
我不知道为什么图书模型没有得到后备按摩.我已经设置 config.i18n.fallbacks = true
.
I don't know why the book model doesn't get the fallback massage. I have set config.i18n.fallbacks = true
.
推荐答案
给出:default 选项时,如果缺少翻译,则将返回其值:
When a :default option is given, its value will be returned if the translation is missing:
I18n.t :missing, :default => 'Not here'
# => 'Not here'
更多信息此处
这篇关于如何在Rails 3中使用I18n后备功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文