File: translating-content.md

package info (click to toggle)
mkdocs-static-i18n 1.3.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,412 kB
  • sloc: python: 3,131; xml: 45; makefile: 21; sh: 17
file content (118 lines) | stat: -rw-r--r-- 2,696 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Translating content

**Focus on translating your content**, not on updating all the links and references to your files!

Let `mkdocs-static-i18n` do the heavy lifting of dynamically localizing your assets and just reference everything without their localized extension.

Since the generated `site` files have their localization extension removed during the build process, you **must** reference them in your markdown source without it (this includes links to `.md` files)!

This simple docs structure:

```
docs
├── image.en.png
├── image.fr.png
├── index.fr.md
├── index.md
```

Will generate this site tree:

```
site
├── fr
│   ├── image.png
│   ├── index.html
├── image.png
├── index.html
```

Which means that the `image.png` and its `fr/image.png` localized counterpart can be referenced the same way as `![my image](image.png)` on both `index.md` and `index.fr.md` when using the `suffix` docs structure.

It works the same for the `folder` structure!

!!! tip
    You may find useful to inform users that some pages are not translated (yet) by [injecting content on an announcement block](https://github.com/ultrabug/mkdocs-static-i18n/issues/276#issuecomment-1785900709) when a page is displayed using its fallback language and thus missing a translation.

## Translating admonitions

This sub-option is a key/value mapping set per language and allows you to translate [admonition](https://python-markdown.github.io/extensions/admonition/) titles which don't have an explicit title defined.

Also, this configuration will apply to [PyMdown Details Extension][details], if the extension is enabled.

[details]: https://facelessuser.github.io/pymdown-extensions/extensions/details/

### Language Sub-Option: `admonition_translations`

This example overrides admonition titles of the French version of the site.

``` yaml
plugins:
  - i18n:
    languages:
      - locale: en
        default: true
        name: English
      - locale: fr
        name: Français
        admonition_translations:
          - tip: Conseil
          - warning: Avertissement

markdown_extensions:
  - admonition
  - pymdownx.details
```

and translates French markdowns:

=== "admonitions"
    From:

    ```
    !!! tip

        Bonjour le monde
    ```

    to:

    ```
    !!! tip "Conseil"

        Bonjour le monde
    ```

=== "details"
    From:

    ```
    ??? tip

        Bonjour le monde
    ```

    to:

    ```
    ??? tip "Conseil"

        Bonjour le monde
    ```

=== "details (open)"
    From:

    ```
    ???+ tip

        Bonjour le monde
    ```

    to:

    ```
    ???+ tip "Conseil"

        Bonjour le monde
    ```