无法更新 js.composer.error.post_length 的文本

我正在尝试更新 js.composer.error.post_length 的文本。在生产环境、暂存环境和我的本地环境中都遇到了这个问题,版本为 2.9 和 3.1.0.beta2。

在前端显示 [missing {{min}} value],尽管值已设置。

错误日志显示:

NoMethodError (undefined method `scan' for {:one=>"Post must be at least %{count} character", :other=>"Post must be at least %{count} characters"}:Hash keys = text.scan(pattern) ^^
Message

NoMethodError (undefined method `scan' for {:one=>"Post must be at least %{count} character", :other=>"Post must be at least %{count} characters"}:Hash

    keys = text.scan(pattern)
               ^^^^^
)
lib/i18n/i18n_interpolation_keys_finder.rb:6:in `find'
app/models/translation_override.rb:123:in `check_interpolation_keys'
app/models/translation_override.rb:64:in `upsert!'
app/controllers/admin/site_texts_controller.rb:88:in `update'
app/controllers/application_controller.rb:414:in `block in with_resolved_locale'
app/controllers/application_controller.rb:414:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:74:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
lib/middleware/missing_avatars.rb:22:in `call'
lib/middleware/turbo_dev.rb:31:in `call'

Backtrace

lib/i18n/i18n_interpolation_keys_finder.rb:6:in `find'
app/models/translation_override.rb:123:in `check_interpolation_keys'
activesupport (7.0.4) lib/active_support/callbacks.rb:400:in `block in make_lambda'
activesupport (7.0.4) lib/active_support/callbacks.rb:199:in `block (2 levels) in halting'
activesupport (7.0.4) lib/active_support/callbacks.rb:687:in `block (2 levels) in default_terminator'
activesupport (7.0.4) lib/active_support/callbacks.rb:686:in `catch'
activesupport (7.0.4) lib/active_support/callbacks.rb:686:in `block in default_terminator'
activesupport (7.0.4) lib/active_support/callbacks.rb:200:in `block in halting'
activesupport (7.0.4) lib/active_support/callbacks.rb:595:in `block in invoke_before'
activesupport (7.0.4) lib/active_support/callbacks.rb:595:in `each'

Env

HTTP HOSTS: 127.0.0.1:3000
2 个赞

该字符串已于 2021 年更改。它使用 %{count} 而不是 %{min},并已转换为复数字符串(one, other)。

您可以通过转到“自定义”–>“文本”来修复自定义字符串:

  • 搜索“js.composer.error.post_length”
  • 点击“编辑”
  • 点击“恢复更改”并用“是”确认问题
  • 点击“返回搜索”
  • 搜索“js.composer.error.post_length”
  • 您将看到 2 个结果,如果需要,请自定义这两个字符串
4 个赞

我想,我们能否构建一种错误处理机制,在这些情况下回退到英语并记录某些内容?

3 个赞

不知何故,我无法让它正常工作,因为出现了 JavaScript 错误“get_attributes”,对话框元素为 null,因此确认对话框没有打开。

但随后我启用了安全模式,检查它是否正常工作,一切都已自动更新。我关闭了安全模式,回到了我的主题,一切又如预期般正常工作。

所以我想安全模式解决了这个问题。并且不再出现上述 JavaScript 错误。(早该试试安全模式了,唉)。

感谢您的帮助!

2 个赞