-
Notifications
You must be signed in to change notification settings - Fork 7
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
i18n French/English language translation #23
Comments
There's probably lots of ways we can go about this, but down the #21 road, sphinx has i18n built in via standard |
it's a lot of maintenance-- i'd rather do english only until someone from the francophone bureau sends me a warning |
I'm not saying we have to make CI a language cop blocking contributions. I'm envisioning a cronjob that detects untranslated texts and sends us an email about it once a month. I'm also not saying this is something we do right now, I just wanted to pin the issue so that like, in 18 months say we have a solution ready. Here's an example of what it can look like when it's functioning: https://docs.godotengine.org/fr/stable/ vs Here's their translation file: https://github.com/godotengine/godot/blob/master/doc/translations/fr.po. It looks like they're actually having to use a tool -- open source -- to manage this because they have a lot of text: https://hosted.weblate.org/projects/godot-engine/godot-docs/ Looks like this thing even makes a TODO list that can be tackled a bit at a time -- even better than my cron idea. Here's what an untranslated string looks like: https://docs.godotengine.org/fr/latest/tutorials/plugins/gdnative/gdnative-c-example.html -- it just gets inlined with a 🤷 This string was updated and so ended up back on weblate's TODO list, with the english |
wow! beyond having a website in multiple languages, i'm mostly interested in trying it just because it looks very cool 😎 |
@taowa corrected me, this is the language policy. Poly's more open to english than UdeM is, because
but still
|
+1 for Weblate usage. I use it in my company for customer's project and it's REALLY easy and nice to use. |
@jcohenadad @kousu Is it OK if I take the lead on this one and create/configure a weblate project for the lab ? I will make sure to document my work and I know how to configure Weblate to use free ACL account for free software like the lab do. |
Spoked with Julien and Nick today. I will prepare Weblate and plug it to the website |
We have a blocker: if we use the free hosted Weblate, our documentation must be under a libre license. Right now there's no formal license attached to the text of the site/wiki, so it defaults to All Rights Reserved by all the individual contributors. @RignonNoel did some researches and decided that CC-BY-4.0 or CC-BY-NC-4. are the most common and simplest options right now. We will need to get the consent of everyone who has contributed, like @alexfoias and @ahill187, to get their consent for the transition. |
I did a bunch of integration test yesterday with the official server of Weblate and the official repo of neuropoly, but I discover some problems I did not expect... 1 - The generation of the POT fileIn order for weblate to work, we need to have the Sphinx I see two options:
2 - Bug on pages when I18N is activated@kousu found out that when I activated I18N some pages became unavailable. We do not know the exact reason for the moment, we will need to do some analysis. We can try to generate a unique po/pot file for all the website, maybe it will fix any potential problem of naming (ex: README.md VS README.po) |
To address
issue in #23 (comment) another option may be to use pre-commit hooks. |
We can't really run pre-commit hooks because when someone clicks the green Commit button the commit happens, unless we start forcing every change to go through a PR first, and force every PR to have a pre-commit check that enforces translations. I think if we do that then we make maintaining the wiki less appealing than it already is. I've been imagining that we rotate translation duty around the lab and have everyone spend one hour a week on it, patching up translations for contributions added in that week. But I like the idea of automating as much as possible! What we can do is run a post-commit hook: add |
Oh actually come to think of it: If we do rotate translation duty around once a week, then we only need to update the .pot file once a week as well. We can use |
I continued the investigation and I have something working in local. However, when I tried to see how to Basically Sphinx is just a generator of static page, and it does not really support I18N but just allow us to build in one language of our choices based on multiple locales we could have been prepared before. So we need to manually:
During my research I found this nice article that explain overall the system we need. Toggle of the languageI did not found how to use the nice ReadTheDoc display on the bottom left of the But I have a first solution with two link on the bottom left Problem is that this manual solution redirect to homepage... As on the article I linked and I think it's really less interesting than the nice Read The Docs integration that keep the URL. DeploymentTo build the different language and store them in specific folder we can try reusing the script of the article: buildDocs.sh I already tried to use the make html with some options with I think we will be forced to use directly Since the scope of the project grow every step I dig into it would be nice to have your opinion @kousu before I implement this new architecture, just to make sure I do not put too much time in it if you don't want to approve all theses change of process. |
These are good researches, @RignonNoel. I think it's fine that I took a closer look at my original example; Godot actually has two repos, with the first containing the .po files from Weblate, and the second the original source text, and the first instructs ReadTheDocs to combine both and to run language = os.getenv("READTHEDOCS_LANGUAGE", "en") So their deployment is rather complicated, and that's what a successful i18n project looks like. It looks on par with what you found. Still, I think we can probably shorten it. I don't think we need Instead, if we patch the Makefile like this: diff --git a/Makefile b/Makefile
index d4bb2cb..b9e83e2 100644
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,12 @@ help:
.PHONY: help Makefile
+html: html-en html-fr
+ @echo -n # no-op, to override the catch-all below
+
+html-%:
+ @language=$* $(SPHINXBUILD) -b html "$(SOURCEDIR)" "$(BUILDDIR)/$*" $(SPHINXOPTS) $(O)
+
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile And diff --git a/conf.py b/conf.py
index 88139f4..a6fb717 100644
--- a/conf.py
+++ b/conf.py
@@ -22,7 +22,7 @@ import os.path
project = 'NeuroPoly Internal Wiki'
copyright = '2021, NeuroPoly'
author = 'NeuroPoly'
-
+language=os.environ.get('language', 'fr')
# -- General configuration ---------------------------------------------------
@@ -94,7 +94,7 @@ for dir, dirs, fnames in os.walk("."): #XXX "." is possibly buggy? This isn't ne
dirs[:] = [d for d in dirs if d not in exclude_patterns] # prune the search
for fname in fnames:
if os.path.splitext(fname)[0] == "README":
- z = os.path.join("_build", "html", dir, "index.html")
+ z = os.path.join("_build", language, dir, "index.html")
#html_extra_path.append(z)
os.makedirs(os.path.dirname(z), exist_ok=True)
if os.path.lexists(z): then
(of course, in my copy, the contents are both in English because I don't have the .po files you are working with). And then we just have to adjust the publish script to match: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 753be90..930cc2e 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -31,5 +31,5 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- publish_dir: _build/html
+ publish_dir: _build/
cname: intranet.neuro.polymtl.ca (I'm not sure why but if I used
Right. This is because we're using More, we should be able to, using jinja2, get the path to the current page, so that we can generate the link to the other language without losing the user's place. I think probably the function we need is
|
@RignonNoel, est-ce que ton prototype est partageable? Envoyerais-tu le comme un PR? Je pourrais te donner des meilleures commentaires si je peux faire marcher le même code. |
@RignonNoel do you know what technology is behind the translation of this page? https://engerlab.com/ (see button top right). the source of the page mentions a "gtranslate" so I am wondering if google offers options to add a button at the top of a website for translation. |
Oui et non, il y a pas grand chose a partager puisque en terme de code c'est tres petit. C'est plus des questions de processus et d'essai/erreur pour demystifier ce qui est possible ou non a travers chacune des documentations puisque le processus complet n'etait disponible nul part. Mais puisqu'on est d'accord je vais mettre tout cela en place et partager une PR |
I did some research and I found this product: https://gtranslate.io/ It seems to be a plugin/widget/tool that you can install on top of your website and that will auto-translate your content based on some provider like GoogleTranslate. Technically it seems to work with a simple JQuery (Javascript) that will transform the page dinamically on demand.
|
Thank you for looking into this. Should we consider gtranslate in light of the possible difficulties/roadblocks with the current sphinx/weblate strategy? |
@jcohenadad Legaly it work if we put the repo in french and add the button for auto-translate in english. And bonus.. An auto-translation is a lot less work for maintain in the time:
But automatic translation is good only for "common" content that google translate succeed to translate correctly. If you have tiny details or a lot of accronyms and expert word its clearly not a good idea. Sadly, I think it's the case for us. So IMHO I think it's not a good strategy for our use case |
We should make an effort to make our site bilingual. We're contravening the language policy (unless Poly has a separate policy from UdeM?) and, I mean, the writing's on the wall with loi 96.
The text was updated successfully, but these errors were encountered: