{"id":5179,"date":"2016-03-15T12:58:33","date_gmt":"2016-03-15T15:58:33","guid":{"rendered":"http:\/\/blog.plataformatec.com.br\/?p=5179"},"modified":"2016-03-15T12:58:59","modified_gmt":"2016-03-15T15:58:59","slug":"using-gettext-to-internationalize-a-phoenix-application","status":"publish","type":"post","link":"http:\/\/blog.plataformatec.com.br\/2016\/03\/using-gettext-to-internationalize-a-phoenix-application\/","title":{"rendered":"Using Gettext to internationalize a Phoenix application"},"content":{"rendered":"

To translate or not to translate? We have been asking ourselves the same question in one of our latest Phoenix projects. Even though internationalizing our application is planned a bit ahead in our roadmap, we have decided to do an initial evaluation of the translation tools in the Elixir ecosystem, and we were pleasantly surprised by what it has to offer.<\/p>\n

The Phoenix framework ships with internationalization (i18n) and localization (l10n) system called Gettext since version 1.1. Gettext<\/strong> is a tool for writing multilingual programs used as a standard by many communities, meaning there is a great set of tooling for developers and translators.<\/p>\n

Let’s start!<\/h2>\n

The idea behind Gettext is that it translates messages based on the string itself and not on “keys”. For example, instead of specifying translations as keys, as in translate \"view.welcome\"<\/code>, we simply use the gettext \"Hello there!\"<\/code> function for every string in the app.<\/p>\n

We have noticed this approach comes with two large benefits:<\/p>\n