I18n not displaying the right locale

I have a pretty simple website structure and I’m having issues with Middleman 4.1.10 and i18 0.7.0 where it displays the wrong locale in some cases.

Here’s the problem in a nutshell:
— The default language is :en
/ the menus are in English. This is correct.
/es the menus are in Spanish. This is correct.
/en/services the menus are in English. This is correct.
/en/servicios the menus are in Spanish. This is correct.
/en/about the menus are in English. This is correct.
/en/sobre-nosotros the menus are in Spanish. This is correct.

However:
/en/alveus the menus are in Spanish. This is incorrect.
/es/alveus the menus are in Spanish. This is correct.

/en/faq the menus are in Spanish. This is incorrect.
/es/faq the menus are in Spanish. This is correct.

Not sure if it’s related but it seems i18n gets confused when the sub-folder has the same name on both languages, I tried changing the name of /en/faq/ to /en/faqs but it still renders the menus in Spanish.

Could this be a bug or am I doing something wrong?


This is my current folder structure (summarized):

- locales
  - en.yml
  - es.yml
- source
 - index.html.erb
 - layouts
   - layout.erb
 - localizable
   - en
     - alveus
     - about
     - faq
     - services
   - es
     - alveus
     - sobre-nosotros
     - faq
     - servicios

This is my config.rb


configure :development do
activate :i18n,
:mount_at_root => ‘en’,
:lang_map => { :‘en’ => ‘en’, :‘es’ => ‘es’ },
:path => ‘/’
activate :sprockets
end

helpers do
def local_path(path, options={})
lang = options[:language] ? options[:language] : I18n.locale.to_s
“/#{lang}/#{path}”
end
end


As a side note: if I remove all the parameters after activating i18n in config.rb it only shows English menus when I go to /es, even though the console seems to pick up both languages:
== The Middleman is loading
== Locales: en, es (Default en)

From the look of your folder structure, I am assuming you are having a copy of the same page for each language. So, instead of:

 - localizable
   - en
     - alveus
     - about
     - faq
     - services
   - es
     - alveus
     - sobre-nosotros
     - faq
     - servicios

I believe the correct way is to do:

 - localizable
   - alveus
   - about
   - faq
   - services

If you do need a separate copy for each language for translated content, then you could try:

 - localizable
   - alveus.en.html.erb
   - alveus.es.html.erb
   - about.en.html.erb
   - about.es.html.erb
   - faq.en.html.erb
   - faq.es.html.erb
   - services.en.html.erb
   - services.es.html.erb

If you want to translate the url paths, according to Middleman’s doc, you can add a paths map in locale files.

Hope this helps.

Thanks, that did the trick.
I guess I miss understood the documentation.

For future reference, I re-organized my folder structure and this is what it looks like:

- localizable
  - alveus
    - index.en.html.erb
    - index.es.html.erb
  - faq
    - index.en.html.erb
    - index.es.html.erb
  - services
    - index.en.html.erb
    - index.es.html.erb
  - about
    - index.en.html.erb
    - index.es.html.erb

And this is my es.yml:


paths:
about: “sobre-nosotros”
services: “servicios”
contact: “contact”
alveus: “alveus”