Say I have the following in config.rb
:
activate :i18n, mount_at_root: false, langs: ['en-us', 'es-mx']
langs.each do |locale|
data.people.each do |k, v|
proxy "/#{locale}/people/#{v.name}.html", "/localizable/templates/people.html", locals: { person: v }, lang: locale
end
end
This works great generating dynamic pages such as /en-us/people/jane.html
and /es-mx/people/jane.html
.
However, I’m not seeing how to implement translated/localized paths for these dynamic pages. For template-based files you can use https://middlemanapp.com/advanced/localization/#localizing-paths. But using my code above say I want people
to be translated to gente
.
I tried the following setup:
# /locales/es-mx.yml
es-mx:
paths:
people: gente
# config.rb
langs.each do |locale|
data.people.each do |k, v|
proxy "/#{locale}/#{I18n.t('paths.people', locale: locale)}/#{v.name}.html", "/localizable/templates/people.html", locals: { person: v }, lang: locale
end
end
When looking at the sitemap the URLs end up like the following:
/en-us/translation missing: en-us.paths.portraits/jane.html
/es-mx/translation missing: es-mx.paths.portraits/jane.html
- etc.
I had activated I18n before this section in my config.rb
. The I18n#translate
method seems available, but none of the actual translation data seems present. Is there a better way to accomplish all this?