Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug(?) sign_in being used, getting removed #470

Open
softwaregravy opened this issue Aug 9, 2022 · 2 comments
Open

Bug(?) sign_in being used, getting removed #470

softwaregravy opened this issue Aug 9, 2022 · 2 comments

Comments

@softwaregravy
Copy link

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.

@davidwessman
Copy link
Collaborator

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.

@timkrins
Copy link

timkrins commented Aug 16, 2022

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

## Root directories for relative keys resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants