As proposed in #23 I extended this plugin instead of providing a custom implementation: easier to see what's going on!
This adds the ability to extend the dictionary on a per-page basis by reading the available data in the context (e.g. data added in the frontmatter) and pulling it in under the i18n key.
This lets you add translations in the frontmatter for a specific page that might use a layout shared across languages, enabling you to add one-off translations that won't clutter up your base dictionaries.
Example
📄 src/en/about.njk
---
title: About
layout: layouts/about.njk
i18n:
favouriteFood: Lasagna
---
Hi, I am an example.
📄 src/fr/about.njk
---
title: À Propos
layout: layouts/about.njk
i18n:
favouriteFood: Lasagnes
---
Bonjour, je suis un exemple.
As proposed in #23 I extended this plugin instead of providing a custom implementation: easier to see what's going on!
This adds the ability to extend the dictionary on a per-page basis by reading the available data in the context (e.g. data added in the frontmatter) and pulling it in under the
i18n
key.This lets you add translations in the frontmatter for a specific page that might use a layout shared across languages, enabling you to add one-off translations that won't clutter up your base dictionaries.
Example
📄 src/en/about.njk
📄 src/fr/about.njk
📄 src/_includes/layouts/about.njk
The
favouriteFood
key does not exist inen.json
orfr.json
but can be accessed by adding it to each localised content file.