使用 I18n-tasks add-missing 时的保留键

问题描述 投票:0回答:1

我正在开发一个 Ruby on Rails 应用程序。

我从一开始就使用 i18n-tasks gem。

我的“i18n-tasks add-missing”命令从未引起任何问题,我已经有2-3周没有使用它了,当我使用它时,现在,我收到下面的错误消息。 ...

我陷入困境,无法解决问题。

 GESTION git:(AddKitchen) ✗ i18n-tasks add-missing
/home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-1.14.4/lib/i18n/backend/base.rb:65:in `translate': reserved key :default used in "Value. Interpolates: %{value}, %{human_key}, %{key}, %{default}, %{value_or_human_key}, %{value_or_default_or_human_key}" (I18n::ReservedInterpolationKey)
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-1.14.4/lib/i18n.rb:363:in `block in translate_key'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-1.14.4/lib/i18n.rb:362:in `catch'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-1.14.4/lib/i18n.rb:362:in `translate_key'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-1.14.4/lib/i18n.rb:222:in `translate'
from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/command/dsl.rb:46:in `block in t'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:188:in `try_call'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:155:in `block in optparse_args'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:155:in `map!'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:155:in `optparse_args'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:92:in `block (2 levels) in optparse_command!'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:91:in `each'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:91:in `block in optparse_command!'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/3.1.0/optparse.rb:1102:in `initialize'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:90:in `new'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:90:in `optparse_command!'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:80:in `optparse!'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:73:in `parse!'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:50:in `block in run'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-1.14.4/lib/i18n.rb:322:in `with_locale'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:49:in `run'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:18:in `block in start'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:211:in `auto_output_coloring'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:17:in `start'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:11:in `start'
        from /home/quentin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.13/bin/i18n-tasks:15:in `<top (required)>'
        from /home/quentin/.rbenv/versions/3.1.4/bin/i18n-tasks:25:in `load'
        from /home/quentin/.rbenv/versions/3.1.4/bin/i18n-tasks:25:in `<main>'

我不明白发生了什么事。我尝试逐页删除内容,看看是否与我的代码有关,但一定是环境的问题,因为它没有解决任何问题。

该错误涉及“:default”键的使用,但在搜索我的应用程序时,我在 en.yml 文件或代码中都没有键(通过 grep 命令 - r 完成搜索)

我尝试进行捆绑更新,但这也没有解决任何问题。

我试图回到我的主人,我已经很长时间没有修改了,一切工作正常,但与我的分支上的错误相同......

ruby-on-rails ruby rubygems internationalization rails-i18n
1个回答
0
投票

我正在使用

  • 红宝石:3.2.4
  • i18n-任务:1.0.13

我的解决方案是

  1. 降级i18n:
    gem "i18n", "1.14.1"
  2. 始终使用
    bundle exec
    ,如
    bundle exec i18n-tasks add-missing

我必须同时做这两件事才能使其发挥作用。

© www.soinside.com 2019 - 2024. All rights reserved.