Iteration K1: Selecting the Locale
We start by creating a new configuration file that encapsulates our knowledge of what locales are available and which one is to be used as the default:
| #encoding: utf-8 |
| I18n.default_locale = :en |
| |
| LANGUAGES = [ |
| ['English', 'en'], |
| ["Español".html_safe, 'es'] |
| ] |
This code is doing two things.
The first thing it does is use the I18n module to set the default locale. I18n is a funny name, but it sure beats typing out internationalization all the time. Internationalization, after all, starts with an i, ends with an n, and has eighteen letters in between.
Then the code defines a list of associations between display names and locale names. ...
Get Agile Web Development with Rails 5.1 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.