-
Notifications
You must be signed in to change notification settings - Fork 36
Workflow for JSON dump files
The Localisation repository contains an objects folder. The JSON files in this folder can be used by translators to easily update strings in the objects repository. This document is intended to detail the workflow used to exchange information between these so-called dump files and the official JSON objects.
A dump file for one particular language can be created by invoking language_dump.py
, e.g.:
$ ./language_dump.py \
-l ja-JP \
-d ja-JP-all.json
This will create a file ja-JP-all.json
containing all object strings, ordered by filename. It may be more practical to order them by English identifier, however. This is not done by the script, but can easily be done with a tool like jq
:
$ jq 'to_entries | sort_by(.value."reference-name") | from_entries' \
< ja-JP-all.json \
> ja-JP-all-sorted.json
This takes ja-JP-all.json
, orders its entries by their reference-name
keys, and outputs the ordered version to ja-JP-all-sorted.json
.
The same script, language_dump.py
, can be used to create dump files for all languages:
$ mkdir dumps
$ ./language_dump.py -a -t dumps
This will export one dump file for each supported languages to the dumps
folder. The locale name will be used as filename, combined with a '.json' extension.
As with any single dump file, the object keys will be ordered in filesystem order. We can employ jq
to reorder them automatically as well:
$ mkdir dumps_sorted
$ for f in dumps/*.json; do \
jq 'to_entries | sort_by(.value."reference-name") | from_entries' \
< $f \
> dumps_sorted/$(basename $f); \
done
This takes all files in the dumps
folder, orders their entries by their respective reference-name
keys, and outputs the ordered versions the dumps_sorted
folder.