I was trying to translate the data files, but it gave no effect. I learned from @bep’s tips from Can data files be translated?.
-
shortcodes/themes.yaml
:
{{ $data := (index .Site.Data.themes .Site.Language.Lang) }}
{{ range $data.icons }}
{{ $iconi := . }}
<!-- ... -->
<tr>
{{ range $tr }}
{{ $tri := . }}
{{ $th := $tri.th }}
<th class="c">
{{ i18n $th }}
</th>
{{ end }}
</tr>
<!-- ... -->
{{ end }}
Tree:
data
├── themes
│ ├── en
│ │ └── themes.yaml
│ └── fr
│ └── themes.yaml
└── themes.yaml
-
data/themes/en/themes.yaml
:
icons:
- name: adwaita-plus
title: Adwaita++
table:
thead:
- tr:
- th: Name
- th: Preview
-
data/themes/fr/themes.yaml
:
icons:
- name: adwaita-plus
title: Adwaita++
table:
thead:
- tr:
- th: Nom
- th: Aperçu
Update
Sorry, @inwardmovement’s answer worked:
{{ $data := (index .Site.Data.themes .Site.Language.Lang) }}
{{ range $data.themes.icons }}
<tr>
{{ range $tr }}
{{ $tri := . }}
{{ $th := $tri.th }}
<th class="c">
{{ $th }}
</th>
{{ end }}
</tr>
{{ end }}