All threads / Creating an application Multi Language

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Creating an application Multi Language

Kelvin Firmino asked in Rails

Hi, good evening.

Cris, I would like to create a system which will suport many language. For instance, I would like to be able to access the languages using URL like:

https://www.mysite.com/us/
https://www.mysite.com/es/
https://www.mysite.com/br/

How is the best way to implement it?

Secondly, Imagine that is it a game application where I will be able to save the monsters data like having more than 30 colums representing the monster information like:

id, name, info1, info2, ..., info30.

How the database should be model to be able to manage multi-language? I suppose that create 30+ columns for each language would not be a good idea. Keeping in mind that it could be translate for mor than 5 languages.

If I create one table to each language, how could Active model handle the right table to get the correct data?

The same would apply to create posts to this website, the post would be translate for all the language supported.

Thanks for your time and attention.

Sincerely,

Kelvin Firmino

Hey Kelvin,

I'm not too familiar with it, but you might try this gem: https://github.com/globalize/globalize

It can help you on the ActiveRecord model side to handle languages using a translations table it looks like.

Ok, thanks.

I will check this gem.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 37,344+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.