Translate tags / taxonomies?

I am trying to translate tags in Hugo.

My tags are only declared in the metadata of my posts:

---
author: arthur.sw
date: 2007-01-01T00:00:35Z
tags:
  - experiment
  - reflection
---

... post content ...

I translated them in my language files:

/i18n/en.toml:

[Experiment]
one = "Experiment"
other = "Experiments"

[Reflection]
one = "Reflection"
other = "Reflections"

/i18n/fr.toml:

[Experiment]
one = "Expérience"
other = "Expériences"

[Reflection]
one = "Réflexion"
other = "Réflexions"

But it never translates the tags, no matter if I use capital letters or not.

I also tried to modify my layouts/_default/list.html:

[...]

        <h1 class='title'>
          {{- if eq .Kind "taxonomy" -}}
          <span class='taxonomy-type'>
            {{- ( ( i18n .Data.Singular 1 ) | default .Data.Singular ) | title -}}
            {{- print ": " -}}
          </span>
          {{- end -}}

          {{- i18n .Title -}}
            
        </h1>

[...]

(I added i18n before .Title to translate the taxonomy name) But this does not work either.

How can I translate tags?

Here is the corresponding stackoverflow question.

Similar question here. How to deal with i18n and taxonomies?

I was hoping to be able to use the _index.md files for taxonomies:

With a taxonomy categories, I have the value cs

I create <content>/categories/cs/_index.md, with:

title: "Computer Science"

I create content/categories/cs/_index.fr.md, with:

title: "Informatique Fondamentale"

Then on for a page summary, I would list its categories and display their title:

{{ range .Params.categories }}
  {{ .Title }}
{{ end }}

This doesn’t work now because {{ . }} is just the string name of the category.

Correct.

You will need to get the category page with .GetPage

{{ .Site.GetPage "taxonomy" "categories" "cs" }}

In your context:

{{ range .Params.categories }}
  {{ $.Site.GetPage "taxonomy" "categories" .).Title }}
{{ end }}
2 Likes

Hi, same question here.
Is there some documentation somewhere about how to deal with taxonomies and i18n ?

googled for the same question and found this thread.
When I create a new _index.lang.md with the translated title in the proper directory like tags or categories inside the content directory the creates the translated files but without the taxonomies standard listing.

lol had to add a post.lang.md and added tags there he generated the file I wanted.