Commit c45ae32
committed
Preliminary support multilingual
mdBook does not natively support multilingual documentation. A common
approach is to use a third-party library like mdbook-i18n-helper, which
relies on a Gettext-based workflow to enable multilingual support.
However, I believe such a complex system is unnecessary for our case.
Therefore, this commit follows the approach suggested in the official
mdBook documentation: overriding the 'index.hbs' template to add a
button that redirects users to the corresponding documentation in
another language, thus achieving basic multilingual support.
This commit introduces the following three files under the theme
directory:
- 'index.hbs': Adds a redirect button for switching languages.
- 'lang-toggle.css': Defines the styling for the button and the dropdown
menu.
- 'lang-toggle.js': Implements the main logic behind the button's
behavior.
As a result, two separate books need to be built. However, since
mdBook’s 'book.toml' does not support multiple '[book]'' sections in a
single configuration, this commit introduces a CMake script to build
different language versions of the book and place them in their
respective directories.
You can test this using command 'cmake -P build.cmake'. If you want to
use 'mdbook serve', you can test it by adding the '-DSERVE=ON' flag.
This will build all the languages listed in the build script and copy
them into the directory generated by mdbook serve.
Due to mdBook's behavior, the 'src' field in 'book.toml' determines the
root URL. Therefore, if the theme directory is placed above the src
directory, mdBook will copy it relative to the 'src' path during the
build, which will cause the theme folder to become unreachable.
Since English is the primary language of this documentation, the default
behavior supports running 'mdbook' command directly from the guide
directory, such as with 'mdbook serve'. However, this will only generate
the English version of the documentation, other languages will not be
built. To build other language versions using the mdbook command
directly, it must manually adjust their respective book.toml files.
All translations are placed under 'guide/translations'. To add a new
language, it need to follow the same folder structure, update the CMake
script, and register the new language in 'theme/index.hbs'.
[1]: https://github.com/google/mdbook-i18n-helpers1 parent 5c1613c commit c45ae32
File tree
44 files changed
+2801
-2
lines changed- .github/workflows
- guide
- theme
- translations
- zh-TW
- src
- dear_imgui
- getting_started
- initialization
- rendering
- shader_objects
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
44 files changed
+2801
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments