#2529·middleman

Problem with i18n when page is not translated to all target languages

Author: guillerodriguezCreated Jan 28, 2022Updated Oct 3, 2025
Labelsnotstale

Expected behavior and actual behavior

I have a Middleman site which is translated to 4 languages: en, es, de, fr. i18n config is as follows:

ruby
activate :i18n, :langs => [:en, :es, :de, :fr], :mount_at_root => false

For most pages there is a single source file which lives under source/localizable; i18n-specific strings are translated via the <%= t('key') %> helper. This works fine.

For some pages, though, there are different language specific versions.

If a language-specific version is available for all languages, then this works fine as well. Let's assume I have:

  • source/localizable/test.html.erb
  • source/localizable/test.es.html.erb
  • source/localizable/test.fr.html.erb
  • source/localizable/test.de.html.erb

If I build the site then all works as expected.

However if the language-specific version is missing for some languages, then the "default" version seems to be used for all languages. Let's assume I have:

  • source/localizable/test.html.erb
  • source/localizable/test.es.html.erb

When I build the site, I see that the default version is used for French and German (good) but also for Spanish (bad)

Not sure if this is related but in the build log I see:

      create  build/en/test.html
      create  build/es/test.html
      create  build/fr/test.html
      create  build/de/test.html
   identical  build/es/test.html

The Spanish page is being processed twice -- but both times with the wrong content (the content for the default language).

Steps to reproduce the problem (from a clean middleman installation)

See above.

Additional information

  • Ruby version: ruby 2.6.8p205 (2021-07-07 revision 67951) [arm64-darwin20]
  • Middleman version: I was using 4.3 but this is also reproducible with 4.4.2
  • OS version: macOS BigSur 11.6 with Apple M1