Skip to content

Commit

Permalink
Updated documentation for language overrides
Browse files Browse the repository at this point in the history
docs: clarify overriding of translations for non-English language
  • Loading branch information
squidfunk authored Sep 20, 2021
2 parents 166096d + 174cb04 commit 8fa40fa
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions docs/setup/changing-the-language.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,22 @@ 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.

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

``` html
{% macro t(key) %}{{ {
<!-- Use en language as fallback -->
{% import "partials/languages/en.html" as fallback %}
{% macro override(key) %}{{ {
"toc.title": "On this page"
}[key] }}{% endmacro %}
<!-- Re-export the translation macro for mkbuild-material to use -->
{% macro t(key) %}{{ override(key) or fallback.t(key) }}{% endmacro %}
```

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

0 comments on commit 8fa40fa

Please sign in to comment.