Translating layout partials

It does not seem possible to translate layout partials, am I right? Or am I missing something?

I have a partial layouts/partials/footer.html which is included into my homepage layouts/_index.html via layouts/_default/baseof.html.

I’d love to be able to have a translated layouts/partials/, but that does not work unless I also have a layouts/ and layouts/_default/ These are identical to the original (default-language) versions, except for the explicit inclusion of the partial. As a result, I have a lot of duplicate code.

It’d be so elegant if a translated partial would be respected without the additional layout files. Possible at all?

The lookup is literal, so ther is no “language file extension magic” going on for partials, so in that sense you are right.

But you do still have some translation options left:

  • You can externalize the strings into /i18n
  • If you want to split into partial per language (or something), you can create your own naming scheme and use that in your templates. A tip here would be to use .Site.Language.Lang and printf and possibly also templates.Exists to check if the partial exists for a given language, and then fall back to some default.