Move translation files

This commit is contained in:
Guillaume Meunier
2025-01-21 21:34:58 +01:00
committed by Patrick Nicolas
parent f183818daa
commit 59a992b201
11 changed files with 93 additions and 71 deletions
+2 -7
View File
@@ -8,18 +8,15 @@ sed -i 's/charset=CHARSET/charset=UTF-8/g' $WIVRN_POT
RC=0
for i in $(find client/locale -name wivrn.po)
for i in locale/*
do
tools/check_po.py $WIVRN_POT $i
tools/check_po.py $WIVRN_POT $i/wivrn.po $(basename $i)
if [ $? != 0 ]
then
RC=1
fi
done
rm $WIVRN_POT
for i in $(find dashboard -name "wivrn_*.ts")
do
cp $i $i.bak
@@ -32,8 +29,6 @@ do
if [ $? != 0 ]
then
RC=1
echo ::warning file=$i::$i is not up to date
fi
rm $i.new
+14 -17
View File
@@ -11,6 +11,7 @@ parser = argparse.ArgumentParser(
parser.add_argument('ref', type=pathlib.Path)
parser.add_argument('file', type=pathlib.Path)
parser.add_argument('lang', type=str)
args = parser.parse_args()
@@ -18,25 +19,23 @@ po_ref = polib.pofile(args.ref)
po_file = polib.pofile(args.file)
entries = [i.msgid for i in po_file.translated_entries()]
language = po_file.metadata['Language']
def flagize(str_in):
str_out = ''
for i in str_in:
str_out += chr(ord(i) + ord('🇦') - ord('A'))
return str_out
flags = {
'Spanish': flagize('ES'),
'French': flagize('FR'),
'Italian': flagize('IT'),
'Japanese': flagize('JP')
# Map language code to a country flag
countries = {
'es': 'es',
'fr': 'fr',
'it': 'it',
'ja': 'jp'
}
if language in flags:
flag = flags[language]
if args.lang in countries:
country = countries[args.lang]
else:
flag = ''
country = args.lang
flag = ''
for i in country.upper():
flag += chr(ord(i) + ord('🇦') - ord('A'))
missing = 0
for i in po_ref:
@@ -46,6 +45,4 @@ for i in po_ref:
print(f"::warning file={args.file}::{flag} Translation for {repr(i.msgid)} is missing")
if missing > 0:
print(f"::warning file={args.file}::{flag} {missing} missing translation(s) in {language}")
sys.exit(1)
+24 -8
View File
@@ -2,17 +2,33 @@
cd $(dirname $0)/..
echo Generating template
WIVRN_POT=$(mktemp)
xgettext --keyword=_:1,1t --keyword=_S:1,1t --keyword=_F:1,1t $(find client/ -name "*.cpp" | sort) --output=$WIVRN_POT --package-name=WiVRn
sed -i 's/charset=CHARSET/charset=UTF-8/g' $WIVRN_POT
WIVRN_CLIENT_POT=$(mktemp)
for i in $(find client/locale -name wivrn.po)
xgettext \
--c++ --from-code=UTF-8 \
--keyword=_:1,1t \
--keyword=_S:1,1t \
--keyword=_F:1,1t \
--output=$WIVRN_CLIENT_POT \
--package-name=WiVRn \
$(find client/ -name "*.cpp" | sort)
sed -i 's/charset=CHARSET/charset=UTF-8/g' $WIVRN_CLIENT_POT
LANGS="es fr it ja"
for i in $LANGS
do
echo Updating $i
msgmerge --quiet --no-fuzzy-matching --update $i $WIVRN_POT
mkdir -p locale/$i
if [ ! -f locale/$i/wivrn.po ]
then
cp $WIVRN_CLIENT_POT locale/$i/wivrn.po
else
msgmerge --quiet --no-fuzzy-matching --update locale/$i/wivrn.po $WIVRN_CLIENT_POT
fi
done
rm $WIVRN_POT
rm $WIVRN_CLIENT_POT
lupdate dashboard/*.{cpp,ui} -ts dashboard/wivrn_*.ts