I would like to have multilingual taxonomies: “tags” in English, and its equivalent in Spanish: “etiquetas”, so each site has their own urls with their proper language. In config.toml
I define:
[languages.en.taxonomies]
tag = "tags"
[languages.es.taxonomies]
tag = "etiquetas"
This way I can use them in front matter like: in English: tags: ..
, in Spanish: etiquetas: ...
. and then the urls are like that too /tags/..
, /es/etiquetas
/.
The problem is when I create a partial or shortcode that makes use of that taxonomy, I can’t access the Page singular form (“tag”) but can only access the plural form (“tags” or “etiquetas”).
Is there a way to access the singular form so I can use access the taxonomy from a partial being aware of Site’s current language?
Currently I define a mapping in a Data file taxonomy_tags.yml
:
en: tags
es: etiquetas
And then access it from a shortcode like:
{{$tags_taxonomy := index $.Site.Data.taxonomy_tags $.Site.Language.Lang }}
{{$tags := $.Page.GetTerms $tags_taxonomy}}
<strong>{{ T "tag" (len $tags)}}</strong>
{{ range $i, $tag := $tags }}
{{if gt $i 0}},{{end}} <a href="{{ $tag.Permalink }}">{{ title $tag.LinkTitle }}</a>
{{ end }}
Is there any other way to avoid maintaining a data file with mappings and have the above functionality?
Using the above set up at simpleit-hugo-theme/layouts/partials/list_tags_in_page.html theme.