From 174cb04ffee916cb431794455e2ea9b8995eb080 Mon Sep 17 00:00:00 2001 From: Dan Cortel Date: Mon, 20 Sep 2021 19:38:36 +0300 Subject: [PATCH] docs: clarify overriding of translations for non-English language --- docs/setup/changing-the-language.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/setup/changing-the-language.md b/docs/setup/changing-the-language.md index 433643814..4c53f2280 100644 --- a/docs/setup/changing-the-language.md +++ b/docs/setup/changing-the-language.md @@ -178,7 +178,7 @@ Click on a tile to change the directionality: [:octicons-file-code-24: Source][1] ยท :octicons-mortar-board-24: Difficulty: _easy_ -If you want to customize some of the translations for your language, just follow +If you want to customize some of the translations for a language, just follow the guide on [theme extension][9] and create a new partial in `partials/languages`, e.g. `en-custom.html`. Next, look up the translation you want to change in the [base translation][1] and add it to the partial. @@ -186,9 +186,14 @@ want to change in the [base translation][1] and add it to the partial. Let's say you want to change "__Table of contents__" to "__On this page__": ``` html -{% macro t(key) %}{{ { + +{% import "partials/languages/en.html" as fallback %} +{% macro override(key) %}{{ { "toc.title": "On this page" }[key] }}{% endmacro %} + + +{% macro t(key) %}{{ override(key) or fallback.t(key) }}{% endmacro %} ``` Then, add the following lines to `mkdocs.yml`: