Skip to content

Customize mdbook for translations, add KO #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 2, 2025
Merged

Conversation

karnkaul
Copy link
Member

@karnkaul karnkaul commented May 2, 2025

No description provided.

Mes0903 and others added 7 commits March 29, 2025 00:53
* Preliminary multilingual support

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.
It can be tested by command 'cmake -P build.cmake'.

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-helpers

* Stick to 'snake_case' for filenames

* Stick to 'snake_case' for file reference
* Add build book job to CI

* Test book build breakage

* `execute_process()`: treat errors as fatal

* Revert deliberate breakage
* ko-translate getting_started

* ko-translate initialization.md

* ko-translate rendering

* ko-translate ImGui

* ko-translate shader_objects

* ko-translate memory

* ko-translate descriptorSets

* revise and summary

* fix

---------

Co-authored-by: Karn Kaul <karnkaul@gmail.com>
@karnkaul
Copy link
Member Author

karnkaul commented May 2, 2025

CC: @CDDing

@karnkaul karnkaul marked this pull request as ready for review May 2, 2025 04:25
@karnkaul karnkaul merged commit f35bf87 into main May 2, 2025
8 checks passed
@karnkaul karnkaul deleted the feature/translations branch May 2, 2025 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants