comparison libgui/languages/build_ts/update_ts_files @ 31537:5ceb4bfcdb0f stable

add tools and files for updating the gui's language files for translation * libgui/languages/build_ts/README.md: readme for updating language files * libgui/languages/build_ts/octave-qsci: QScintilla source files for languages without translation provided by QScintilla * libgui/languages/build_ts/octave-qt: Qt source files for languages without translation provided by Qt
author Torsten Lilge <ttl-octave@mailbox.org>
date Thu, 24 Nov 2022 06:48:25 +0100
parents
children cbdd37c5a223
comparison
equal deleted inserted replaced
31535:4b80982e0af8 31537:5ceb4bfcdb0f
1 #!/bin/bash
2
3 # This scripts has to be called from the folder libgui/languages
4 # where the *.ts files for each provided translation are located
5
6 # The paths with libgui sources to scan for text strings
7 SEARCH_PATH_COMMON="../graphics ../qterminal ../src"
8
9 # Path to Qt and QScintilla files with strings that should also be
10 # translated by octave in case that Qt or QScintilla does not provide
11 # translations for the current language
12 SEARCH_PATH_QT="build_ts/octave-qt"
13 SEARCH_PATH_QSCI="build_ts/octave-qsci"
14
15 # Alwys add Qt search query widget since no translation is provided by Qt
16 SEARCH_PATH_COMMON="$SEARCH_PATH_COMMON $SEARCH_PATH_QT/qhelpsearchquerywidget.cpp"
17
18 # The directory with translations provided by Qt and QScintilla
19 QT_LANG_DIR=/usr/share/qt5/translations
20
21 # Now update all ts files
22 for file in *.ts; do
23
24 xx=${file:0:2}
25 xx_yy=${file:0:5}
26
27 # Set the search path to the minimal one used for each ts file
28 SEARCH_PATH=$SEARCH_PATH_COMMON
29
30 # Look for translations provided by Qt and QScintilla and extend the search
31 # path if no existing translations are found. In this case we have to scan
32 # the locally collected source files.
33 if [ $xx_yy != "en_US" ]; then # No trnaslation required for en_US
34 # Look for Qt translations
35 if [ "`ls $QT_LANG_DIR | grep -i qt_$xx.qm | wc -l`" -eq 0 ] &&
36 [ "`ls $QT_LANG_DIR | grep -i qt_$xx_yy.qm | wc -l`" -eq 0 ]; then
37 SEARCH_PATH="$SEARCH_PATH $SEARCH_PATH_QT"
38 echo "QT"
39 fi
40 # Look for QScintilla translations
41 if [ "`ls $QT_LANG_DIR | grep -i qscintilla_$xx.qm | wc -l`" -eq 0 ] &&
42 [ "`ls $QT_LANG_DIR | grep -i qscintilla_$xx_yy.qm | wc -l`" -eq 0 ]; then
43 SEARCH_PATH="$SEARCH_PATH $SEARCH_PATH_QSCI"
44 echo "QSCI"
45 fi
46 fi
47 echo
48 echo
49
50 # Do the update after user's confirmation
51 echo "$file => scan for strings in following paths"
52 echo " => $SEARCH_PATH"
53 read -p " => Update (y/[n])? " ANS;
54 ANS=${ANS:-n}
55 if [ $ANS = "y" ]; then
56 echo
57 lupdate -qt5 -no-obsolete -locations relative $SEARCH_PATH -ts $file
58 fi
59
60 done
61
62 echo