-
Notifications
You must be signed in to change notification settings - Fork 56
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
Language Selector :) #394
base: main
Are you sure you want to change the base?
Language Selector :) #394
Conversation
I'm also not sure if there's a standards-compliant way to signal that there are multiple languages available for a given page at different URLs, but if so we should do that. edit: oop i guess you can't declare env variables like that in nox. it works in dev mode with |
This is awesome!!! Thank you for trying this 👏 |
This is awesome and I think it is exactly what we were thinking about! 😍 The code for the Japanese language is About the language lists and how the selector is populated, here are some clarifications from the nox file perspective:
|
Love, love, love this @sneakers-the-rat. Thank you! |
aha, so yes some of these problems are from the special-casing of
Would it be alright if we just followed node/rails and did like Then we can switch which languages are included that way and be relatively sure of it.
restoring this now, i saw that previously but them being empty was making me sad lol. I don't have strong opinions at all, but maybe another thing we could do is publish all started translations and then on pages that haven't been translated add a message like "this isn't translated yet, but you can help us translate!" with a link to docs or to the relevant .po file?
this is one of the reasons i wanted to single-source this. sphinx should use the same list that nox is using when building so these don't get out of sync, i'll clean this up a bit now |
… separate build_languages from languages in conf.py
OK I updated so
The main reason why this is such a pain is that 1) sphinx doesn't handle having a the other source of complexity is that normally language building is switched like |
Yeah that was a way for the docs-test to indicate to the build-translations session that it should only builds the RELEASE_LANGUAGES. Calling the build-translations directly (without that argument) will build all LANGUAGES.
Sure, I think that is fine
It's a good idea but I am not sure how to do that with Sphinx. The .po files are not one to one with the original files, it's more one to one with the sections.
👍 |
I saw this and preserved it :) now the same behavior can be done by passing
I found a config option that adds CSS classes to blocks/divs that indicates their translated status: https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-translation_progress_classes So I think we can make this visible in-page just with CSS classes, and perhaps add some JS to add a little banner at the top if there are untranslated changes to a page. There is also a substitution (hadn't ever used a docutils substitution before) that prints a percentage like :::{eval-rst}
|translation progress|
::: though I dont know how useful that would be unless I can style it with JS/put it in the sidebar/not in main text. You're right tho I think linking out from an untranslated section to the relevant lInes in the .po file might be too tricky to be worth it, but we could link out to the whole .po file relatively easily by just parsing the URL I think? Normally I would say lets save these for another PR but since this PR would make translations "live" on the site it might be worth getting all the things we would want roughly in place here, or else collect a few PRs in a |
Wanted to help out the translation effort, but since i am a reprehensible monolingual don't have much to add.
Here's a draft of adding a language selector and making the translated builds a more regular part of the build process (existing stuff in the noxfile was already nicely done!)
language_selector.mp4
some notes
I put the "smarts" about locations into the templating process rather than in the javascript. this gives us some hope of being reusable in some way (maybe) since you have to know about the subdirectory you're in on the server somehow, and afaik the only good way to know that is from the
base_url
, which isn't available in the js (i could have embedded it in some empty HEAD element or something but i sorta like this better). I think that screenreaders don't readvalue
but rather the label, but i will double check.anyway that lets the js be nice and simple :)
it looks like the precommit action did something funky to my jinja templates (L3-9 in language_selector.html ) splitting it out across multiple lines. not sure if that's valid, so may have to figure out how to ignore that line in precommit or w/e.
I couldn't find a good way to fork a process or run concurrent processes with
nox
( wntrblm/nox#198 (comment) ) so I just usedconcurrently
in the global env... not the best so lmk if y'all know of a better way (probably python would be good so it can be installed by nox?). anyway it builds all the languages in parallel in dev mode and doesn't make stdout a nightmare by labeling them:single-sourced the languages from the
conf.py
file, hopefully thats ok, wanted to make it easy to add new languages.didn't do styles yet, wanted to see if this general approach seemed ok before i went hogwild.