How do I go about localizing data string that come from yaml files stored in the data folder
wondered if there were some techniques I have missed for this.
One way i am aware of, is using symbols (pointing to translation items) within your data:
/data/product.yml
title: :product_title
/config.rb
set :lang, :de
activate :i18n, :langs => [:de, :en]
These symbols can be translated as (Middleman) usual ...
/locales/de.yml
---
de:
product_title: "Mein deutscher Produktname"
/locales/en.yml
---
en:
product_title: "My english product title"
... and used in your templates:
/source/localizable/i18n.html.erb
<h1><%= I18n.t(data.product.title) %></h1>
http://0.0.0.0:4567/i18n.html
Mein deutscher Produktname
http://0.0.0.0:4567/en/i18n.html
My english product title