-
Notifications
You must be signed in to change notification settings - Fork 131
I18n Proposition
The i18n
directory contains the code for the translator.
For each language, there will be a dictionary file containing translation for the terms in the textbook under the directory ai_files/{locale_code}
. The translator iterates through ai_files
to know what languages to translate to. These files together with the English XMLs will be fed into the translator, which outputs translated XMLs that will be stored into the branch called translated_xmls
under this repo.
When the repo is deployed, besides generating docs_out
for the English XMLs, the translated XMLs will be cloned from translated_xmls
and will also run through the scripts generating docs_out
.
.github/workflows/translate-changed.yml
, .github/workflows/translate-everything.yml
are responsible for calling the translator, while .github/workflows/deploy-pages.yml
is responsible for the deployment.
Following is the complete process of the workflow:
- Check whether there are changes of the English XMLs. (using
tj-actions/changed-files
) - If there are, the translator will be triggered to translate the changed English XMLs into other languages and store the output in
i18n/translation_output
, which will be pushed totranslated_xmls
usingpeaceiris/actions-gh-pages@v4
. - Run the generating scripts on the English XMLs.
- Clone
translated_xmls
, and run the generating scripts for each language. - Deploy
docs_out
to https://sicp.sourceacademy.org
In the frontend
repo, a selection menu for the language of the textbook will be implemented.
Use npx tsx index.ts
or yarn trans
to invoke the translator. In the following part, <trans>
refers to either of the two.
-
<trans> test <section> <lang>
: translate (e.g. 1.1, 1.1.2) to (e.g. zh_CN), used for debugging -
<trans> abs
: "abs" stands for absent. translate every section to every language if the translation does not exist or the modification time is older than the English XML itself, used for local testing. -
<trans>
,<trans> all
: translate every section to every language -
<trans> <path1> <path2> ...
: translate the English XMLs at the paths<path1>,<path2>,...
to every language.