You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
Bash
46 lines
1.3 KiB
Bash
1 year ago
|
#!/bin/bash
|
||
|
|
||
1 year ago
|
git_top_level=$(git rev-parse --show-toplevel)
|
||
|
|
||
1 year ago
|
if [ $# -eq 0 ]; then
|
||
1 year ago
|
echo "Please specify a language to update"
|
||
1 year ago
|
exit 1
|
||
|
fi
|
||
|
|
||
1 year ago
|
language_file="$git_top_level/src/lang/extra/$1.txt"
|
||
1 year ago
|
|
||
|
# Check that the specified file exists
|
||
|
if [ ! -f "$language_file" ]; then
|
||
|
echo "File not found: $language_file"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
1 year ago
|
in_override_section="true"
|
||
1 year ago
|
# Read each line from the English file and check if it exists in the language file
|
||
|
while read -r line; do
|
||
1 year ago
|
# Check if we have reached the end of the override section
|
||
|
if [[ $line == "##override off" ]]; then
|
||
|
in_override_section="false"
|
||
|
continue
|
||
|
fi
|
||
|
|
||
|
# Skip lines before the end of the override section
|
||
|
if [[ $in_override_section == "true" ]]; then
|
||
|
continue
|
||
|
fi
|
||
|
# Skip other lines that start with #
|
||
1 year ago
|
if [[ $line =~ ^#.* ]]; then
|
||
|
continue
|
||
|
fi
|
||
|
# Extract the string code from the English line
|
||
1 year ago
|
STRING_CODE=$(echo $line | cut -d':' -f1 | tr -d '[:space:]')
|
||
1 year ago
|
# Check if the string code exists in the language file
|
||
1 year ago
|
if ! grep -q "$STRING_CODE" "$language_file"; then
|
||
1 year ago
|
# If the line doesn't exist, add it to the end of the language file
|
||
|
echo "$line" >>"$language_file"
|
||
|
echo "Added missing line to $language_file: $line"
|
||
|
fi
|
||
1 year ago
|
done <"$git_top_level/src/lang/extra/english.txt"
|
||
|
cd $git_top_level/src/lang/
|
||
|
perl $git_top_level/utils/conv-lang.pl
|