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)