What support does ruby have for internationalization? I have heard that ruby on rails doesn't support a large amount of character sets. I am in the midst of rolling out a international application and need to ofcourse make sure that rails can support every character set possible. Some I need initially are UTF8, Big 5, Shift JIS. Can rails handle this?
People succeed in answering Don Miguel de los Platanos's questions 42% of the time (8 successes in 19 attempts).
Answers by: Rich Collins | Adam Thorsen | Fear of Fish | skwp
I was just thinking of a cool way to do i18n. Create a helper method called i18n. Make the parameter to the method the default language text:
<%= i18n("I like cats") %>
That will output I like cats if the user is set up as the default language. If they are using a different language, It would look up the entry corresponding to "I like cats" in the db, and then choose the appropriate translation.
Say the user decided they wanted the site in Spanish. It would look up the row for "I like cats":
def i18n(text)
user.translate(text)
end
#in user.rb
def translate(text)
t = Translation.find_by_text(text)
t.translate(user.language)
end
#in translate.rb
def translate(language)
send(language)
end
So then you could just add columns to the translations table. If you added "spanish" as a column to the translations table, and set the user's language to "spanish". It would return the spanish version - "Me gusta gatos". This would work pretty well. You could even let the users translate for you like a wiki!