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

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.

You want to create a rake task that

A) Reads the CSV and for each row (Probably, depends on your CSV): B) Finds the existing file, changes the local, and adds the data.

Since you are familiar with Railscasts, have a look at #66 Custom Rake Tasks - RailsCasts for an overview of making your own rake tasks.

This link is what you probably ultimately want to do: http://nithinbekal.com/2009/rails-importing-data-from-spreadsheets-into-database/