i18n-tasks
i18n-tasks copied to clipboard
Bug(?) `sign_in` being used, getting removed
I am in a Rails 7 app with i18n-tasks (1.0.11)
in my Gemfile Lock. and I am running i18n-tasks remove-unused --keep-order
After running this, my app fails with translation missing: en.shared.landing_layout.sign_in
The key is indeed removed, per git diff:
shared:
- landing_layout:
- sign_in: "Log in"
- sign_up: Sign up
My Rails app has devise views generated. The stack trace:
[app/views/devise/sessions/new.html.erb:5](http://localhost:3000/users/sign_in#)
[app/views/shared/_landing_layout.html.erb:9](http://localhost:3000/users/sign_in#)
[app/views/devise/sessions/new.html.erb:1](http://localhost:3000/users/sign_in#)
The users/sign_in renders the layout. (app/views/devise/sessions/new.html.erb)
1 <%= render layout: "shared/landing_layout" do %>
The layout yields to the contents of new. (app/views/shared/_landing_layout.html.erb)
9 <%= yield %>
Which then has the sign_in link (app/views/devise/sessions/new.html.erb)
5 <%= t(".sign_in") %>
I am not that familiar with how Rails resolves the keys, but it has resolved this key to be en.shared.landing_layout.sign_in
as evidenced by the stack trace. Devise generated locale files as well. These were not modified by the above command.
I think there might be a bug related to relative translations in partials vs the Rails behaviour. To avoid the issues now you can use the absolute path to the translation.
I haven't used relative roots myself, but have you set up the relative roots configuration in i18n-tasks.yml
?
https://github.com/glebm/i18n-tasks#relative-keys
https://github.com/glebm/i18n-tasks/blob/03bd88f5f4e69e236a4701d77ce7d78ad2c09ad7/templates/config/i18n-tasks.yml#L59