Skip to content
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

Package a language selector #12

Open
mgeisler opened this issue Apr 4, 2023 · 1 comment
Open

Package a language selector #12

mgeisler opened this issue Apr 4, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@mgeisler
Copy link
Collaborator

mgeisler commented Apr 4, 2023

Currently, you have to edit the mdbook theme directly to add a language selector. An example of this can be seen in Comprehensive Rust 🦀.

We should package this up in some way to make it easy for people to apply. This seems non-trivial because the templating system used in mdbook doesn't seem to make it easy to include new blocks of code without editing the main theme.

Some ideas:

  • Inject JavaScript into the pages and let this code build the menu client-side.
  • Write a tool which can modify the generated HTML to include the menu when mdbook build is called.
@dalance
Copy link
Contributor

dalance commented Nov 28, 2024

Inject JavaScript into the pages and let this code build the menu client-side.

I realized this idea at https://github.com/dalance/translations/blob/master/rust-by-example/theme/language-picker.js .
By this approach, translation can be achieved without modifing the original book only by inserting two files to additional-css and additional-js entry.
This is a part of rust-lang/rust#133562 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants