Iteration J1: 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 it defines a list of associations between display names and locale names. Unfortunately, ...

Get Agile Web Development with Rails 5, 1st Edition 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.