Wrapping up i18n

Yesterday I was able to wrap up the internationalization of the site. It took us a while to figure out how we wanted the user to choose languages. We have several options: A setting on the browser can decide; users can indicate their preferences in the user account; we can have the location of your IP address decide for you. In the end we opted for the language link approach. No flags in our case, just links with the name.

Once the links were made, the next challenge was to make the language choices stick. In order to accomplish this, I had to set all link methods in our rails application attach the ?locale parameter automatically. In practice this meant that every link helper in any of our pages would generate the right language after we had already set the variable for locale at least once. If you didn’t do anything the locale would default to English.

Hard links were a completely different matter. Thus far, I was only able to find one hard-link to worry about: the link to the about page on the header section. In order to deal with hard links we had to come up with a little rails hack. We (I had help from Eric Rochester figuring this one out) sent a variable from the actual header tag back into the yml file to have the yml file generate the links in the right language. The code looks something like this:

## on app/views/layouts/_header.html.erb

<p class="description"><%= t 'header.description_html', 
:about_url => url_for(:controller => 'pages', :action => 
'about') %></p>

## on the config/locales yml files

   description: >
      Prism es un conjunto de herramientas que sirven 
      para <a href='%{about_url}'>colectivizar la
      interpretación </a>de textos... 

Textual critic, high theory acolyte, archive rat, hard-hat Caribbeanist, Rails aficionado, conference-trotter. My thesis focuses on the evolution of the play Et les chiens se taisaient by Aimé Césaire. Other projects include: an edition of Césaire, THATCampCaribe, a better Juxta, a class on #critcode, and Prism at the Praxis Program.

Comments are closed.