Iterate and display a message for all languages regardless of current page's language

I’m building a custom 404 page. I want it to display some translated error message. I also want it to display the same error message in all of my site’s configured languages (in case someone ends up there somehow and doesn’t speak that language).

I have the following code which I would expect to work. It does display the correct language, but it always translates the i18n key to the current language.

    {{ range .Site.Sites }}
      {{ with .GetPage "/404" }}
      <p>{{ .Language }} - {{ T "pageDoesntExist" . }}</p>
      {{ end }}
    {{ end }}

Any ideas what I’m doing wrong? Or is this not possible b/c 404 pages are special or something?

Thanks in advance.

1 Like

What you want to do is not possible using the i18n function. See

But you can cheat…

site config

source = 'data'
target = 'data'

source = 'i18n'
target = 'data/translations'


{{ range .Site.Languages }}
  {{ index site.Data.translations .Lang "foo" }}
{{ end }}

This works fine for simple translations, but not for translations with pluralization rules. For example…


foo = 'foo DE'
bar = 'bar DE'
1 Like

@jmooring Thanks so much. I’ll give it a go.