| 1 |
# Localizing Your Theme |
| 2 |
|
| 3 |
Display your theme in your preferred language. |
| 4 |
|
| 5 |
--- |
| 6 |
|
| 7 |
NOTE: |
| 8 |
Theme localization only translates the text elements of the theme itself |
| 9 |
(such as "next" and "previous" links), not the actual content of your |
| 10 |
documentation. If you wish to create multilingual documentation, you need |
| 11 |
to combine theme localization as described here with a third-party |
| 12 |
internationalization/localization plugin. |
| 13 |
|
| 14 |
## Installation |
| 15 |
|
| 16 |
For theme localization to work, you must use a theme which supports it and |
| 17 |
enable `i18n` (internationalization) support by installing `mkdocs[i18n]`: |
| 18 |
|
| 19 |
```bash |
| 20 |
pip install 'mkdocs[i18n]' |
| 21 |
``` |
| 22 |
|
| 23 |
## Supported locales |
| 24 |
|
| 25 |
In most cases a locale is designated by the [ISO-639-1] (2-letter) abbreviation |
| 26 |
for your language. However, a locale may also include a territory (or region or |
| 27 |
county) code as well. The language and territory must be separated by an |
| 28 |
underscore. For example, some possible locales for English might include `en`, |
| 29 |
`en_AU`, `en_GB`, and `en_US`. |
| 30 |
|
| 31 |
For a list of locales supported by the theme you are using, see that theme's |
| 32 |
documentation. |
| 33 |
|
| 34 |
- [mkdocs](choosing-your-theme.md#mkdocs-locale) |
| 35 |
- [readthedocs](choosing-your-theme.md#readthedocs-locale) |
| 36 |
|
| 37 |
WARNING: |
| 38 |
If you configure a language locale which is not yet supported by the theme |
| 39 |
that you are using, MkDocs will fall back to the theme's default locale. |
| 40 |
|
| 41 |
## Usage |
| 42 |
|
| 43 |
To specify the locale that MkDocs should use, set the [locale] |
| 44 |
parameter of the [theme] configuration option to the appropriate code. |
| 45 |
|
| 46 |
For example, to build the `mkdocs` theme in French you would use the following |
| 47 |
in your `mkdocs.yml` configuration file: |
| 48 |
|
| 49 |
```yaml |
| 50 |
theme: |
| 51 |
name: mkdocs |
| 52 |
locale: fr |
| 53 |
``` |
| 54 |
|
| 55 |
## Contributing theme translations |
| 56 |
|
| 57 |
If a theme has not yet been translated into your language, feel free to |
| 58 |
contribute a translation using the [Translation Guide]. |
| 59 |
|
| 60 |
[Translation Guide]: ../dev-guide/translations.md |
| 61 |
[locale]: configuration.md#locale |
| 62 |
[theme]: configuration.md#theme |
| 63 |
[ISO-639-1]: https://en.wikipedia.org/wiki/ISO_639-1 |