2023-03-05 12:32:32 +00:00
#!/bin/bash
2023-03-06 21:48:11 +00:00
# This file is part of OpenTTD.
# OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
# OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
2023-03-05 15:03:41 +00:00
git_top_level = $( git rev-parse --show-toplevel)
2023-03-05 12:32:32 +00:00
if [ $# -eq 0 ] ; then
2023-03-05 15:03:41 +00:00
echo "Please specify a language to update"
2023-03-05 12:32:32 +00:00
exit 1
fi
2023-03-05 15:03:41 +00:00
language_file = " $git_top_level /src/lang/extra/ $1 .txt "
2023-03-05 12:32:32 +00:00
# Check that the specified file exists
if [ ! -f " $language_file " ] ; then
echo " File not found: $language_file "
exit 1
fi
2023-03-05 13:22:15 +00:00
in_override_section = "true"
2023-03-05 12:32:32 +00:00
# Read each line from the English file and check if it exists in the language file
while read -r line; do
2023-03-05 13:22:15 +00:00
# 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 #
2023-03-05 12:32:32 +00:00
if [ [ $line = ~ ^#.* ] ] ; then
continue
fi
# Extract the string code from the English line
2023-03-05 13:15:09 +00:00
STRING_CODE = $( echo $line | cut -d':' -f1 | tr -d '[:space:]' )
2023-03-05 12:32:32 +00:00
# Check if the string code exists in the language file
2023-03-05 13:15:09 +00:00
if ! grep -q " $STRING_CODE " " $language_file " ; then
2023-03-05 12:32:32 +00:00
# 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
2023-03-05 15:03:41 +00:00
done <" $git_top_level /src/lang/extra/english.txt "
cd $git_top_level /src/lang/
perl $git_top_level /utils/conv-lang.pl