Iterating over translated content in the config file

I am translating the index page. Some content in config file is common for all languages, some changes. In nested structures when I translate partially and reference directly everything works, i.e.:

languages:
  en:
    params:
      home:
        button:
          text: Home
  de:
    params:
      home:
        button:
          text: Titelseite
params:
  home:
    button:
      url: /

so in the template when I refernce it direclty via something along the lines of:

<a href="{{ .Site.Params.home.button.url }}>{{ .Site.Params.home.button.text }}</a>

everything works. The problem starts when I would like to have a list of some kind, let’s say, affiliated sites:

languages:
    en:
       params:
         sites:
           - description: A friendly site 1
           - description: A friendly site 2
    de:
       params:
         sites:
           - description: eine freundliche Website 1
           - description: eine freundliche Website 2
params:
  sites:
    - url: friendly-website-1.com
    - url: friendly-website-2.com

Simple iteration via range shows only translated “copy” of the map entry, so there is description element but url is empty. I tried to iterate via {{ range $i, $v := .Site.Params.sites }} and then reference elements via {{
(index .Site.Params.sites $i).url }}
but it does not work either.

I have also tried to make it a map instead of an actual array, like:

languages:
    en:
       params:
         sites:
           1:
               description: A friendly site 1
           2:
               description: A friendly site 2
    de:
       params:
         sites:
           1: 
               description: eine freundliche Website 1
           2: 
               description: eine freundliche Website 2
params:
  sites:
    1:
      url: friendly-website-1.com
    2:
      url: friendly-website-2.com

But it does not seem to work either. Any ideas how to translate an array like this without repeating all the redundant information that would be common across languages?

Put it in a data/stuff.toml file and load/iterate via site.Data.stuff...?

1 Like