Thanks @MichaelCurrin, you pointed me in the right direction there!
Instead of including the printed title in the _data/[lang]/navbar.yml
, I now have a single _data/navbar.yml
with not the actual texts, but just keys:
# note: entry must match page title key as used in _i18n/en.yml
- entry: about
url: /about
- entry: blog
url: /blog
Which I then use in _includes/nav.html
to create the full string key that the translation plugin can pick up from _i18n/[locale].yml
(instead of simply printing the ‘title’ for each item, taken from the navbar.yml):
{% for link in site.data.navbar %}
{% capture title %}titles.{{ link.entry }}{% endcapture %}
<div class="nav-item ml-2">
<a class="nav-link" href="{{ site.baseurl }}{{ link.url }}">{% t {{ title }} %}</a>
</div>
{% endfor %}
The translations file _i18n/[locale].yml
used by the plugin then looks like this (and if the site is generated in another language, it provides the translated version of the string):
titles:
about: "About"
blog: "Blog"