I18n用于特定于模型的Rails提交按钮 [英] I18n for model-specific Rails submit button

查看:57
本文介绍了I18n用于特定于模型的Rails提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现Rails可以通过config/locales/en.yml中的以下内容来使用通用的提交按钮:

I've found that Rails allows for generic i18n of submit buttons via the following in config/locales/en.yml:

en:
  helpers:
    submit:
      create: "Create %{model}"
      submit: "Save %{model}"
      update: "Update %{model}"

但是,我只想为一种特定型号更新create值.我希望文字显示为"Upload%{model}"或"Upload".如何仅对一个模型(例如Photo模型)进行此更改?

However, I'm looking to update the create value only for one specific model. I'd like the text to read as "Upload %{model}" or just "Upload". How can I make this change for just one model (e.g.: a Photo model)?

推荐答案

来自

From the source code, it looks like you should be able to do this:

en:
  helpers:
    submit:
      post:
        create: "Upload %{model}"

其中,post是模型的名称. 内嵌文档也提到了你可以做到的.

where post is the name of your model. The inline docs also mention that you can do this.

这篇关于I18n用于特定于模型的Rails提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆