Thursday, October 18, 2012

[Rails] Globalize3 gem, upload data from CSV

Rails 3.1.3
Globalize3 latest

I am not sure if I can ask this question here in general Rails forum.
But I'll try.

Currently I am using a gem, Globalize3, which is useful for model I18n.
https://github.com/svenfuchs/globalize3

Say, I have a model City, having only one column, name.
City names appear differently depending on the language, so perhaps this
particular gem is useful.

RailsCast is nice
http://railscasts.com/episodes/338-globalize3?view=comments

My app has already many city names in ENGLISH and now I would like to
add city names in other languages as well. In order to do so, from my
understanding,

find a particular City entry

c = City.find(...)
c.name = "Tokyo"

then I need to change I18n.locale

I18n.locale = :ja

and add the new name in another language

c.name = "東京"
c.save

This is a tedious job. I want to add hundreds of city names from a CSV
file.

Can anyone give me tips for controllers for that?

I am stuck because I need to change I18n.locale on every insertion.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate