3 Add languages
Lukas Schreiner edited this page 6 months ago

Add languages

It is possible to add further languages to lerntools. The procedure is explained in the next chapters.


Following packages are required:

  • Git
  • Node.js
  • NPM

Prepare sources


git clone https://codeberg.org/lerntools/weblate.git
cd weblate


git clone -b dev https://codeberg.org/lerntools/base.git


Note: You can skip those modules, which are not relevant or not supported anymore.

mkdir -p base/modules
git clone -b dev https://codeberg.org/lerntools/abcd.git base/modules/abcd
git clone -b dev https://codeberg.org/lerntools/about.git base/modules/about
git clone -b dev https://codeberg.org/lerntools/ideas.git base/modules/ideas
git clone -b dev https://codeberg.org/lerntools/projector.git base/modules/projector
git clone -b dev https://codeberg.org/lerntools/survey.git base/modules/survey

Add further module (optional)

If you've new modules for translations, adapt this page in chapter modules.

In addition, the file sync.js must be adapted:

// Directories containing vue-locale files of the client repo
const LOCALE_DIRS = {
  "main": "main/locales/",
  "abcd": "modules/abcd/locales/",
  "ideas": "modules/ideas/locales/",
  "projector": "modules/projector/locales/",
  "survey": "modules/survey/locales/"

For example - to add module cool-module:

// Directories containing vue-locale files of the client repo
const LOCALE_DIRS = {
  "main": "main/locales/",
  "abcd": "modules/abcd/locales/",
  "cool-module": "modules/cool-module/locales/",
  "ideas": "modules/ideas/locales/",
  "projector": "modules/projector/locales/",
  "survey": "modules/survey/locales/"

Continue with rest of the guide.

Prepare dependencies

Execute following commands in the root folder of the weblate repository:

npm install

Add language to files

For translation

Edit sync.js file. Have a look at the top of the file:

 * Configuration for Lerntools (don't change if you really know what you'r doing!)

// Supported locales - this entry **MUST** contain at least the entries from export.LOCALES in ./base/consts.js
// see https://de.wikipedia.org/wiki/Liste_der_ISO-639-1-Codes
const LOCALES = ['de', 'en']

Extend the LOCALES array. If you want to add e.g. fr, append it inside of the array at the right position with a comma separated:

const LOCALES = ['de', 'en', 'fr']

Save the file.

For using in application

If a translation round start, there are no text translated and adding the language directly to the production environment is useless. The following steps can be done at a later point of time. If translation is mostly done, file base/consts.js must be edited. Search for:

//Supported languages
exports.SUPPORTED_LANGUAGES=['de', 'en']

Add all languages to the array, you want to offer in Lerntools. To add e.g. fr, extend the line as following:

//Supported languages
exports.SUPPORTED_LANGUAGES=['de', 'en', 'fr']

Generate language files

To prepare the language files for Weblate, execute following statement in the root directory of the weblate repository:

node sync.js

Follow the guide (char $ indicates terminal input, do not copy this char.):

$ node sync.js
1. Please push all changes from weblate, put weblate into maintainance mode and enter "Ye$": Ye$
2. Pulling client and weblate repository
3. Syncing between weblate and client locales
Locales: Add lang main → ABCDList → fr
Locales: Add lang main → Admin → fr
Locales: Add lang main → AdminList → fr
4. Please push all changes in weblate and client repos manually and press [ENTER]
5. Please perform pull in weblate and press [Enter]

Press Enter key if indicated. You can execute the necessary commit, push and pulls in next chapter.

Push the changes

The changes must be published to the repositories. Do following (adapt the commit messages according to your actions done):

$ git add locales/**.json
$ git add sync.js
$ git commit -am "Locales: add language 'fr'"
$ git pull
$ git push

In addition, the changes in modules, etc. must be pushed.

$ pushd "base/" && git commit -am "Locales: prepare language 'fr'" && git push; popd
$ for i in `ls base/modules`; do echo "Update module $i" && pushd "base/modules/$i" && git commit -am "Locales: prepare language 'fr'" && git push; popd; done

You're done.