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

translate title #168

Open
Tealk opened this issue Feb 13, 2024 · 4 comments
Open

translate title #168

Tealk opened this issue Feb 13, 2024 · 4 comments

Comments

@Tealk
Copy link

Tealk commented Feb 13, 2024

hello,

is it possible to translate the titles?

@tommilligan
Copy link
Owner

You can specify a custom title for each block, if that would help.

The default titles aren't currently localized, I think this would be reasonably easy to add as a book.toml configuration option, if you want to work on it I'm open to PRs

@Tealk
Copy link
Author

Tealk commented Feb 14, 2024

Yes, but then I have to do it for every block, it's not quite as nice as central.

The book.toml is a good idea, but I don't really know how the whole system works here. So I don't know if I can contribute to the code. As far as I have noticed, the CSS file is not sufficient to use mdbook-admonish.

@tommilligan
Copy link
Owner

The point where a directive (the thing like note that tells us which type of box to render) is converted to a title is here:

fn title(self, raw_directive: &str) -> String {

Because the number of directives is pretty limited, I wouldn't overthink this, I'd be happy with a big old hardcoded static list of translations by language. We can then decide which set of translations to use by loading a config option from the file, and threading it down like we do with custom directives here:

custom_directives: &CustomDirectiveMap,

It may be the case using an internationalization framework like https://github.com/longbridgeapp/rust-i18n would make it simpler, but it might also make it more complex, kind of up to you which is easier.

The point I would add the config option for book.toml is here:

pub(crate) struct AdmonitionDefaults {

@Tealk
Copy link
Author

Tealk commented Feb 15, 2024

We could use the language = "de" in the book.toml.

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

No branches or pull requests

2 participants