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

Some translations are returned as hash after 1.7.1 #510

Closed
mg-partec opened this issue Jan 9, 2020 · 9 comments
Closed

Some translations are returned as hash after 1.7.1 #510

mg-partec opened this issue Jan 9, 2020 · 9 comments

Comments

@mg-partec
Copy link

What I tried to do

I am developing a Rails 5.2 app with English and Italian languages.
The translations of some model names fail after updating i18n from 1.7.0 to 1.7.1.
Reverting to 1.7.0 fixed the issue.

What I expected to happen

PurchaseOrder.model_name.human count:1
=> "Ordine di acquisto"
PurchaseOrder.model_name.human count:2
=> "Ordini di acquisto"

What actually happened

PurchaseOrder.model_name.human count: 1
=> {:one=>"Ordine di acquisto", :other=>"Ordini di acquisto", :limit_order=>"Ordine al limite", :market_order=>"Ordine a mercato", :order_total=>"Totale ordine", :recurring_order=>{:one=>"Ordine ricorrente", :other=>"Ordini ricorrenti"}, :open=>"Ordini aperti", :reorder=>"Riordina"}

PurchaseOrder.model_name.human count: 2
=> {:one=>"Ordine di acquisto", :other=>"Ordini di acquisto", :limit_order=>"Ordine al limite", :market_order=>"Ordine a mercato", :order_total=>"Totale ordine", :recurring_order=>{:one=>"Ordine ricorrente", :other=>"Ordini ricorrenti"}, :open=>"Ordini aperti", :reorder=>"Riordina"}

Versions of i18n, rails, and anything else you think is necessary

Rails 5.2.4
i18n 1.7.1

Issue is solved reverting to 1.7.0

@radar
Copy link
Collaborator

radar commented Jan 10, 2020

Is this still an issue in 1.8.1?

@ydkn
Copy link

ydkn commented Jan 11, 2020

Still having this issue with 1.8.1

irb(main):007:0> I18n::VERSION
=> "1.8.1"
irb(main):008:0> Device.model_name.human
=> {:one=>"Device", :other=>"Devices", :features=>{:description=>"Description", ...

@radar
Copy link
Collaborator

radar commented Jan 12, 2020

Could you please provide the locale files that you're using? Well, just the relevant parts. That would help me debug this.

@ydkn
Copy link

ydkn commented Jan 12, 2020

I created a new rails app and added a simple i18n yaml to showcase this issue: https://github.com/ydkn/ruby-i18n-issue-510

It has no views but you can test it using the rails console like the example above:

irb(main):001:0> MyModel.model_name.human(count: 2)
=> {:one=>"My Model Translation", :other=>"My Models Translation", :some_other_key=>{:key=>"Value"}}

@radar
Copy link
Collaborator

radar commented Jan 12, 2020

Thank you. I have confirmed this is indeed broken in 1.8.1. My guess is b7f69f7 is responsible. I will look more into this later on.

@radar radar closed this as completed in 1b5e345 Jan 13, 2020
@radar
Copy link
Collaborator

radar commented Jan 13, 2020

This fix for this has been applied in 1b5e345. Thank you very much for letting me know about the issue and providing some really awesome steps to reproduce it.

The fix has been released in i18n 1.8.2. Please upgrade to this version in your applications.

@mg-partec
Copy link
Author

mg-partec commented Jan 13, 2020

Unfortunately in my case the error seems to be still there. Here is another example:

v 1.8.2
Portfolio.model_name.human count: 2
=> {:one=>"Dossier", :other=>"Dossier", :content=>"Contenuto", :earning=>{:one=>"Guadagno", :other=>"Guadagni"}, :mean_paid=>"Media pagato", :total_value=>"Valore totale"}

v 1.7.0
Portfolio.model_name.human count: 2
=> "Dossier"

@chevinbrown
Copy link

This is still an issue if you've formatted translations like this:

ryan_big:
  one: "Ryan"
  other: "Ryans "
  other_things:
    thing1: "Baloons"

Ryan.model_name.human(count: 2) #=> Hash
Removing the nested attributes returns expected behavior.

It seems that translations related to the model, but not necessarily attributes of the model, are nested under the model-key.

@radar
Copy link
Collaborator

radar commented Jan 17, 2020

@chevinbrown Please open a new issue for this, even if it is related. The fix itself may be separate, and so it helps to track that with separate issue numbers.

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

4 participants