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

Change language attribute of the book to configurable #941

Merged
merged 1 commit into from
Jun 24, 2019

Conversation

rnitta
Copy link
Contributor

@rnitta rnitta commented May 30, 2019

Currently the language attribute of the book, which is used like <html lang={{ language }}>, is hardcoded as fixed value en.
I want to use mdBook in Japanese, so make it configurable.

With these changes, we will be able to set the language of the book like:

book.toml

[book]
title = "the title of the book"
authors = ["rnitta"]
src = "src"
language = "ja"

The default value of the language is still en, and no changes of book.toml is required if you want to set language en as same as usual.

@zzy
Copy link

zzy commented May 30, 2019

The default value of the language is still en, and no changes of book.toml is required if you want to set language en as same as usual.

If you init project with --theme, I think it's convenient to set the lang value <html lang="zh" class="..."> in index.hbs.

@rnitta
Copy link
Contributor Author

rnitta commented May 30, 2019

Thanks for comment,
I know the way to set html lang attr by modifying index.hbs,
but not all of mdbook users may initialize with --theme option and
BookConfig.language is currently used only for <html lang="{{ language }}" class="sidebar-visible no-js"> in index.hbs by defaults, so making it configurable will not cause problem. It may increase usability. Maybe. I think.

Thoughts?

@Dylan-DPC-zz
Copy link

@ehuss thoughts on this? looks fine to me

@ehuss ehuss merged commit bb3398b into rust-lang:master Jun 24, 2019
@ehuss
Copy link
Contributor

ehuss commented Jun 24, 2019

Yep! Thanks @rnitta!

@rnitta rnitta deleted the configurable-language branch June 25, 2019 03:01
Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this pull request Aug 30, 2020
Change language attribute of the book to configurable
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.

4 participants