Exams Attended

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Ruby On Rails Interview Questions and Answers

Ques. How can you implement internationalization in Ruby on Rails?

Ruby ships with i18n which is an internationalization gem. 

You need to create locale files and save them under the config/locales directory as:




The keys should match for each of these files. 

en:   main_page:     hello: “Hello”     welcome: “Welcome to   My Company” es:   main_page:     hello: “Hola”     welcome: “Bienvenido a Mi Empresa” fr:   main_page:     hello: “Salut”     welcome: “Bienvenue   Mon Entreprise

In your code you would need to specify that the text would be locale specific. So change it to something like this:

.content   %h1     = t("main_page.hello")  
%p     = t("main_page.welcome")

Then you have to select the actual locale.

Is it helpful? Yes No

Most helpful rated by users:

©2021 WithoutBook