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
  [​'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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.