I18n translation issue on Micro.blog: works Locally, but not on server

Can anyone help me understand why my blog at https://cesco.blog isn’t working correctly with internationalization (i18n)? I’m trying to translate messages from English to Italian.

I’ve set "defaultContentLanguage": "it" in the config.json file and created an it.json file in the i18n folder.

For translation, I’m using {{ i18n "<Value>" }} or the shortcut {{ T "<Value>" }}. This is a brief snippet of my code:

i18n/it.json:

{
    "Archive": "Archivio",
    "Full Post List": "Lista completa degli articoli",
    "Hosted by <a href=\"https://micro.blog\">Micro.blog</a>": "Ospitato da <a href=\"https://micro.blog\">Micro.blog</a>",
    "Powered by <a href=\"https://sumo.micro.blog\">Sumo Theme</a>": "Realizzato con <a href=\"https://sumo.micro.blog\">Sumo Theme</a>",
    "Designed with <span class=\"red\">♥</span> by <a href=\"https://www.mattlangford.com\">Matt Langford</a>": "Disegnato col <span class=\"red\">♥</span> da <a href=\"https://www.mattlangford.com\">Matt Langford</a>"
}

layouts/_default/list.archivehtml.html:

<h2 class="p-name post-title">{{ T "Archive" }}</h2>

[...]

<div class="full-archives h-feed">
    <h3>{{ T "Full Post List" }}</h3>
    {{ $list := (where .Site.Pages "Type" "post") }}
    {{ range $list }}
   
    [...]
</div>

The translations work perfectly on my local computer using Hugo 0.91 but not on micro.blog.

Specifically, the partials/footer.html file translates correctly, but the translations in the layout/_default/list.archivehtml.html layout don’t work.

I’ve experienced the same issue with both Hugo 0.91 and Hugo 0.117.

If you make other changes to layout/_default/list.archivehtml.html, do they go through? For instance, if you change the h2 element to an h3 or temporarily add some gibberish text to the template, do those changes appear?

If they don’t, it’s possible that a plug-in or custom theme in the Micro.blog environment is overriding the template, which might not be present in your local setup.

1 Like

Thank you.
Yes, in fact, there was a file named list.archivehtml.html in the root’s layouts folder that was overshadowing the identical file in the theme’s layouts folder.

I was convinced that the file from the theme was being loaded, but in reality, a different file was being loaded. I’ve now resolved the issue, thanks again.

You’ll find this page helpful for figuring out what layout may actually be overriding your own in the future.

1 Like