Ruby On Rails Interview Questions and Answers
Ques. How can you implement internationalization in Ruby on Rails?Ans.Ruby ships with i18n which is an internationalization gem. You need to create locale files and save them under the config/locales directory as: en.yml es.yml fr.yml 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") Then you have to select the actual locale. |
Is it helpful?
Yes
No
Most helpful rated by users:
- What is Ruby On Rails?
- Why Ruby on Rails?
- Explain how (almost) everything is an object in Ruby.
- What are Gems and which are some of your favorites?
- How would you declare and use a constructor in Ruby?