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

Wrong usage of I18n & missing translations #814

Open
tangopium opened this issue Apr 13, 2024 · 4 comments
Open

Wrong usage of I18n & missing translations #814

tangopium opened this issue Apr 13, 2024 · 4 comments

Comments

@tangopium
Copy link

tangopium commented Apr 13, 2024

There is currently an issue in the teams edit view (that might actually affect other parts of the system too):

First of all, there is a translation missing (which is just a minor issue): In this line I currently (v1.7.2) get the error Translation missing: de.teams.fields.locale.options and there are actually no options here.

The second, more severe issue is the usage of the hash returned from I18n.t here and here (where you try to modify the hash).

This throws the error can't modify frozen Hash. The issue is known and described in detail here. In summary I18n returns a frozen hash since 3.0. The solution should be passing t("locale.locales").clone(freeze: false).

I didn't review the test coverage of BulletTrain, but shouldn't those kind of issue pop up automatically?

@tangopium
Copy link
Author

Actually, when I pass the t("locale.locales").clone(freeze: false), this results in
another issue

@jagthedrummer
Copy link
Contributor

@tangopium thanks for the bug report but I'm having trouble following, and the teams edit view is working as expected for me. Can you please provide reproduction details and a full stack trace of whatever error you're seeing? It's hard to figure out what you're talking about with just links to various lines of code but without any larger context as to how you're getting there.

@lcorneliussen
Copy link

Added a second language to locales.yml. Then both the accounts and settings page fail, as they seem to use locale.locales scoped to the particular views, not referencing locales globally.

When i add missing translations to both languages, the personal account settings show two buttons. But the teams settings fail with can't modify frozen hash in /bullet_train-themes-tailwind_css-1.7.22/app/views/themes/tailwind_css/fields/_buttons.html.erb where line #31 raised.

Will investigate more later today.

Added locales to make the missing translations errors go away:

<language>
  users:
    fields:
      locale:
        options: *locales
  users:
    fields:
      locale:
        options: *locales

@lcorneliussen
Copy link

teams/_form.html.erb has this:

    <% if multiple_locales? %>
      <%= render 'shared/fields/buttons', method: :locale, options: t("locale.locales") %>
    <% end %>

changing it to this (like in users/_form.html.erb fixes it....

    <% if multiple_locales? %>
      <%= render 'shared/fields/buttons', method: :locale, options: {"": t("locale.default")}.merge(t("locale.locales")) %>
    <% end %>

or even this, as i don't know what the locale.default is about

    <% if multiple_locales? %>
      <%= render 'shared/fields/buttons', method: :locale, options: {}.merge(t("locale.locales")) %>
    <% end %>

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