我们的项目中有一些语言环境文件,如下所示:
notice: '%{resource_name} was successfully created.'
alert: '%{resource_name} could not be created.'
我们使用I18n进行翻译。现在,如果我们用俄语翻译某些内容,它看起来是这样的:
notice: '%{resource_name} был успешно создан.'
%{resource_name}是默认翻译,始终为英文。如何使用自己的翻译将其翻译成其他语言?谢谢!
答案 0 :(得分:1)
我假设您的资源是Active Record模型?如果是这样,请检查this part of documentation。
创建翻译文件:
ru:
activerecord:
models:
user: пользователь
然后:
t('notice', resource_name: User.model_name.human)
答案 1 :(得分:0)
对于每个控制器和操作,您可以使用不同的翻译,例如
en:
posts:
create:
notice: "Post was successfully created"
users:
create:
notice: "User was successfully created"
依此类推