mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-11-13 22:05:15 +00:00
Auto sorting of locale files
This commit is contained in:
36
frontend/src/locale/scripts/locale-sort.sh
Executable file
36
frontend/src/locale/scripts/locale-sort.sh
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
set -e -o pipefail
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$DIR/../src" || exit 1
|
||||
|
||||
if ! command -v jq &> /dev/null; then
|
||||
echo "jq could not be found, please install it to sort JSON files."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# iterate over all json files in the current directory
|
||||
for file in *.json; do
|
||||
if [[ -f "$file" ]]; then
|
||||
if [[ ! -s "$file" ]]; then
|
||||
echo "Skipping empty file $file"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$file" == "lang-list.json" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# get content of file before sorting
|
||||
original_content=$(<"$file")
|
||||
# compare with sorted content
|
||||
sorted_content=$(jq --tab --sort-keys . "$file")
|
||||
if [ "$original_content" == "$sorted_content" ]; then
|
||||
echo "$file is already sorted"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Sorting $file"
|
||||
jq --tab --sort-keys . "$file" | sponge "$file"
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user