-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add Localisation Support With Fluent #1201
base: master
Are you sure you want to change the base?
Conversation
2b30411
to
fe44495
Compare
Hmm, I'm not sure if this is the right path for translating books. I18n frameworks is great when you have a lot of formatting and some text, less so for books which are all text. No harm in merging, but I feel that the right path here is typically to translate the entire book as a new book. |
I don't disagree with this idea, but I don't think it entirely applies to There's no obviously correct solution to this problem, but this PR provides a great solution with relatively minimal changes (The commit implementing it is ~350 lines) for the most popular backend, and it also doesn't prevent anyone from continuing to keep separate books if that's the workflow that's what works best for them. |
Right, but it seems like it might be better to add more support for compiling a locales folder of books? |
I did think about that, and I initially tried to write the fluent implementation essentially like that, as I wanted to make it renderer independent. My impression (maybe someone who's more familiar with the code will disagree) was that it would be a lot of work to refactor the existing codebase around that, as you're essentially adding a whole new step (probably to the beginning) of the mdbook compilation lifecycle, this PR side-steps that by being an implementation detail of the very last step of one specific backend. Adding that step would definitely be more than I could contribute currently. Even if this implementation was completed, there are UI/UX concerns around how to present the localisation to the user on the web. If for example different books weren't required to share the same to share the same |
I like this PR. |
This PR adds support in the HTML renderer to localise fluent mdbook projects. It does this by adding a handlebars preprocessing step to the content, chapter title, and book title that allows it use a handlebars fluent plugin. This is a minimal version that people should be able to test. I would love to get feedback on adding testing in mdbook for localising and using the handlebars interface/API.
Localisation User Story
multilingual
, which enables fluent localisation.locales
directory, either by marking a directory with that name, or specifying a directory with thelocales
config variable. Every fluent file in a subdirectory within thelocales
directory who's name matches a valid [Unicode Language Identifier][uni] is loaded into fluent.src
with{{fluent}}
helpers.languages-available
) are localised through the fluent helper in handlebars and generated into markdown. Which is then rendered with the theme as HTML.language
in thebook.toml
, which is generated at the regular path) are generated under a folder matching their identifier.Breaking Changes
LinkPreprocessor
is using its own custom parser and preprocessing step. This means that right now you have to pass helpers through{{{{raw}}}}
handlebars blocks to be picked up. If this change is accepted, theLinkPreprocessor
could be migrated over to work as a handlebars helper directly to avoid this.Future Work
closes #5