设计 i18n 资源
我正在尝试使用区域设置将设计默认语言(英语)翻译为葡萄牙语。我为此找到了一个非常好的资源,它在大多数情况下都可以工作,但是每当我有一个指向语言环境内的资源变量的指针时,它就会给我英文名称。例如,我有一个名为 User 的模型,因此当更新此用户时出现问题时,我想显示一条包含“User”正确翻译的闪存消息,在本例中为“Usuário”。
I'm trying to use locale to translate devise default language (english) to portuguese. I've found a pretty good resource for that, it's working for the most part, but whenever I have a pointer to the resource variable inside the locale it gives me the name in English. For example, I have a model called User, so when something goes wrong while updating this user I would like to show a flash message containing the right translation of "User", in this case "Usuário".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
模型名称翻译应放入 config/locales/pt.yml 中
model names translations should be put to
config/locales/pt.yml
Devise 不使用 ActiveRecord 翻译,可能不与任何 ORM 结合。
我刚刚结束了覆盖设计视图,使用 ActiveRecord 键添加翻译:
要翻译其他消息(不是字段标签),您应该尝试 https://github.com/mcasimir/devise-i18n-views
Devise doesn't use ActiveRecord translations, probably not to couple with any ORM.
I've just ended up overriding devise view adding translation with ActiveRecord keys:
For translating other messages (not field labels) you should try https://github.com/mcasimir/devise-i18n-views