mirror of
https://github.com/knadh/listmonk.git
synced 2025-11-09 17:22:26 +08:00
Update i18n refresh script to remove deleted base keys from all other files.
This commit is contained in:
parent
5f1b676401
commit
9224e344be
1 changed files with 10 additions and 7 deletions
|
|
@ -1,14 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# "Refresh" all i18n language files by merging missing keys in lang files
|
# "Refresh" all i18n language files by merging and syncing keys with the base file.
|
||||||
# from a base language file. In addition, sort all files by keys.
|
|
||||||
|
|
||||||
BASE_DIR=$(dirname "$0")"/../i18n" # Exclude the trailing slash.
|
BASE_DIR=$(dirname "$0")"/../i18n" # Exclude the trailing slash.
|
||||||
BASE_FILE="en.json"
|
BASE_FILE="en.json"
|
||||||
|
|
||||||
# Iterate through all i18n files and merge them into the base file,
|
# Iterate through all i18n files and sync them with the base file.
|
||||||
# filling in missing keys.
|
|
||||||
for fpath in "$BASE_DIR/"*.json; do
|
for fpath in "$BASE_DIR/"*.json; do
|
||||||
echo $(basename -- $fpath)
|
if [ "$(basename -- "$fpath")" = "$BASE_FILE" ]; then
|
||||||
echo "$( jq -s '.[0] * .[1]' -S --indent 4 "$BASE_DIR/$BASE_FILE" $fpath )" > $fpath
|
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
|
done
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue