From bf6d4718e450ce27cc1c0fe5070071c4bef32a1f Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Wed, 14 Apr 2021 13:52:13 +0530 Subject: [PATCH] Add script to merge and normalize i18n files --- scripts/refresh-i18n.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 scripts/refresh-i18n.sh diff --git a/scripts/refresh-i18n.sh b/scripts/refresh-i18n.sh new file mode 100755 index 0000000..b85431d --- /dev/null +++ b/scripts/refresh-i18n.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# "Refresh" all i18n language files by merging missing keys in lang files +# from a base language file. In addition, sort all files by keys. + +BASE_DIR=$(dirname "$0")"/../i18n" # Exclude the trailing slash. +BASE_FILE="en.json" + +# Iterate through all i18n files and merge them into the base file, +# filling in missing keys. +for fpath in "$BASE_DIR/"*.json; do + echo $(basename -- $fpath) + echo "$( jq -s '.[0] * .[1]' -S --indent 4 "$BASE_DIR/$BASE_FILE" $fpath )" > $fpath +done