Search code examples
localizationinternationalizationhamlmiddleman

How Do I Use Localization (i18n) with Haml in Middleman


The examples on Middleman's web page are in ERB, but I like to use HAML.

http://middlemanapp.com/advanced/localization/

This is their example localization YAML file:

---
es:
  hello: "Hola"

And this is how they use ERB to access it.

<%= I18n.t(:hello) %> World

But I prefer HAML to ERB. How does the above line translate into HAML?


Solution

  • This would simply be :

    = I18n.t(:hello)
    World
    

    You might want to put the greeting in your localization file though :

    es:
      hello: "Hola %{name}"
    

    and call it from your HAML like this

    = I18n.t(:hello, :name => 'World')