Skip to content

Commit 8fa40fa

Browse files
authored
Updated documentation for language overrides
docs: clarify overriding of translations for non-English language
2 parents 166096d + 174cb04 commit 8fa40fa

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: docs/setup/changing-the-language.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,22 @@ Click on a tile to change the directionality:
178178
[:octicons-file-code-24: Source][1] ·
179179
:octicons-mortar-board-24: Difficulty: _easy_
180180

181-
If you want to customize some of the translations for your language, just follow
181+
If you want to customize some of the translations for a language, just follow
182182
the guide on [theme extension][9] and create a new partial in
183183
`partials/languages`, e.g. `en-custom.html`. Next, look up the translation you
184184
want to change in the [base translation][1] and add it to the partial.
185185

186186
Let's say you want to change "__Table of contents__" to "__On this page__":
187187

188188
``` html
189-
{% macro t(key) %}{{ {
189+
<!-- Use en language as fallback -->
190+
{% import "partials/languages/en.html" as fallback %}
191+
{% macro override(key) %}{{ {
190192
"toc.title": "On this page"
191193
}[key] }}{% endmacro %}
194+
195+
<!-- Re-export the translation macro for mkbuild-material to use -->
196+
{% macro t(key) %}{{ override(key) or fallback.t(key) }}{% endmacro %}
192197
```
193198

194199
Then, add the following lines to `mkdocs.yml`:

0 commit comments

Comments
 (0)