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 http://railscasts.com/episodes/66-custom-rake-tasks 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/




On 19/10/12 13:34, Soichi Ishida wrote:
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.


--
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to