更改 simple_form 提交按钮 i18n 文本

Changing simple_form submit button i18n text

这是我的代码:

<%= simple_form_for [:backend, @department] do |f| %>
  <%= f.input :parentid, input_html: { class: 'form-control' } %>
  <%= f.input :name, input_html: { class: 'form-control' }  %>
  <%= f.button :submit %>
<% end %>

这是我的表单,我想更改提交文本,现在的文本是 create department,所以我尝试了:

zh-CN:
  simple_form:
    helpers:
      submit:
        department:
          create: "新建部门"
          update: "保存编辑"

但没有任何改变。我该如何更改它?

我添加了一个gem i18n-debug,然后我重新启动服务器并刷新页面。看看终端日志,我就知道是什么问题了。 enter image description here 所以,在 zh-CN 之后是 helpers,而不是 simple_form

布鲁斯韦恩给出了很好的答案。 但是我在 i18n-debug 中遇到了错误:

private method `prepend' called for I18n::Backend::Simple:Class (NoMethodError)

debug.rb

我变了

Backend::Simple.prepend(Debug::Hook)

Backend::Simple.send :prepend, Debug::Hook

而且效果很好!

或者您可以在 Gemfile 中使用补丁 gem:

gem 'i18n-debug', github: 'robotex82/i18n-debug', branch: 'robotex82-patch-1'

来自 https://github.com/robotex82/i18n-debug/tree/robotex82-patch-1

i18n_debug_page 为 i18n 调试信息提供了 UI,如下所示: