Make translations for SAS emoji available in-tree (#2728)

* add a base file

* Fix directory name

* Added translation using Weblate (English)

* Translated using Weblate (English)

Currently translated at 1.6% (1 of 64 strings)

Translation: matrix-doc/SAS Emoji v1
Translate-URL: https://translate.riot.im/projects/matrix-doc/sas-emoji-v1/en_EN/

* add english files

* delete english files

* Added translation using Weblate (English)

* Added translation using Weblate (English)

* Do manual translations

* Deleted translation using Weblate (English)

* Deleted translation using Weblate (English)

* Add a script to update the definitions with the translations

* update i18n

* Add a note to the spec about translations

* changelog

* Ensure translations end with json
This commit is contained in:
Travis Ralston 2020-08-12 14:04:48 -06:00 committed by GitHub
parent 8eb1c53144
commit d37f7a25b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 555 additions and 65 deletions

32
scripts/i18n.py Normal file
View file

@ -0,0 +1,32 @@
#!/usr/bin/env python3
#
# i18n.py: Generate and merge the i18n files for the spec.
import json
import sys
import os
import os.path
scripts_dir = os.path.dirname(os.path.abspath(__file__))
data_defs_dir = os.path.join(scripts_dir, "../data-definitions")
def merge_sas_emoji_v1():
emoji = dict() # will be populated by a read
with open(os.path.join(data_defs_dir, "sas-emoji.json"), encoding="utf8") as f:
emoji = json.load(f)
for e in emoji:
e["translated_descriptions"] = dict()
pth = os.path.join(data_defs_dir, "sas-emoji-v1-i18n")
translations = [t for t in os.listdir(pth) if os.path.isfile(os.path.join(pth, t))]
for translation in translations:
if not translation.endswith(".json") or translation == "base.json":
continue
lang = translation[:-5] # trim off the json extension
with open(os.path.join(pth, translation), encoding="utf8") as lf:
descs = json.load(lf)
for e in emoji:
e["translated_descriptions"][lang] = descs[e["description"]]
with open(os.path.join(data_defs_dir, "sas-emoji.json"), mode="w+", encoding="utf8") as o:
json.dump(emoji, o, ensure_ascii=False, indent=4)
merge_sas_emoji_v1()