Work with translations
If we want to have different languages on our textbook, we need to follow some steps
Preparation
Identify the language you want to translate to from this yaml file and take the name of its key. For example, for japanese, the key is
ja
:
Go to the
config.yaml
file and add the mention key to thelocales
list. Following with the example of adding japanese, thelocales
list will be:
If the notebook translations are on the old textbook repository, go there and copy the files. The japanese notebooks are here
Once we have the notebook translations we want to include on the new texbook, we add it to
/translations/<key-for-the-new-language>
. Thiskey-for-the-new-language
is the same value we added to thelocales
list on the step 2.Create a
toc.yaml file
inside/translations/<key-for-the-new-language>
with the table of content for the specific language. Notice that the file for the original version (english in this case) should be in/notebooks/toc.yaml
Convert notebooks files into md files
By running
we execute the converter. This function converts the notebooks into md files and add the english versions to the /working/content
folder and the translations to the /working/translations/<key-for-the-new-language>
folder
Convert md files into html
By running
mathigon studio converts the md files on the /working/content
and /working/translations/<key-for-the-new-language>
directories into json files in the public
directory that contains the html needed to render the page
⚠️ Known problem
Every course has to start with a section title (##). If it doesn't, the
npm run build:studio
throws an error
Try it on local
On local, you can see if the translations are working by adding the following query parameter to the URL (have in mind that this is the query parameter for the japanese version):
Production
In production, the translations go under a subdomain, and that subdomain should be linked manually in Google Cloud. On our example, it will be: