tdreyno/middleman-i18n — Issue #2: A working config.rb version of your readme code, fwiw
Author: mikemee
Created: 2011-10-27 06:47:19+00:00
State: open

I got this working based on your readme and am using it now in https://github.com/agamz/FindBigMail/blob/master/config.rb

Note the tweak that customizes the filename based on data in the yml file so the source file is pricing.html.haml but it will be generated as es/precios.html given the following es.yml:

```yaml
es:
paths:
pricing: precios
```

The config.rb code:

```ruby
I18n.load_path += Dir[ File.join(Dir.getwd, 'locale', '*.{rb,yml}') ]

langs = Dir["locale/*.yml"].map { |file| File.basename(file).gsub(".yml", "") }
files = Dir["source/localizable/**"]

langs.each do |lang|
I18n.locale = lang
files.each do |file|
src = file.split("source/").last.gsub(".haml", "")
page_id = File.basename(src, File.extname(src))
new_page = "/" + src.gsub("localizable", lang).
gsub(page_id, I18n.t("paths.#{page_id}", :default => page_id))
page new_page, :proxy => src, :ignore => true do
I18n.locale = lang
@lang = lang
@page_id = page_id
end
end
end
```