Files
EagleCast/scripts/refresh-i18n.sh
T
h202-wq 66d9a033c9
publish-github-pages / deploy (push) Waiting to run
EagleCast
2026-07-09 10:03:32 -04:00

18 lines
666 B
Bash

#!/bin/bash
# "Refresh" all i18n language files by merging and syncing keys with the base file.
BASE_DIR=$(dirname "$0")"/../i18n" # Exclude the trailing slash.
BASE_FILE="en.json"
# Iterate through all i18n files and sync them with the base file.
for fpath in "$BASE_DIR/"*.json; do
if [ "$(basename -- "$fpath")" = "$BASE_FILE" ]; then
continue # Skip the base file itself
fi
echo "$(basename -- "$fpath")"
jq -s --indent 4 --sort-keys \
'.[0] as $base | .[1] as $target |
$base | with_entries(.value = ($target[.key] // .value))' \
"$BASE_DIR/$BASE_FILE" "$fpath" > "$fpath.tmp" && mv "$fpath.tmp" "$fpath"
done