view 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
line wrap: on
line source

#!/bin/bash

# This scripts has to be called from the folder libgui/languages
# where the *.ts files for each provided translation are located

# The paths with libgui sources to scan for text strings
SEARCH_PATH_COMMON="../graphics ../qterminal ../src"

# Path to Qt and QScintilla files with strings that should also be
# translated by octave in case that Qt or QScintilla does not provide
# translations for the current language
SEARCH_PATH_QT="build_ts/octave-qt"
SEARCH_PATH_QSCI="build_ts/octave-qsci"

# Alwys add Qt search query widget since no translation is provided by Qt
SEARCH_PATH_COMMON="$SEARCH_PATH_COMMON $SEARCH_PATH_QT/qhelpsearchquerywidget.cpp"

# The directory with translations provided by Qt and QScintilla
QT_LANG_DIR=/usr/share/qt5/translations

# Now update all ts files
for file in *.ts; do

  xx=${file:0:2}
  xx_yy=${file:0:5}

  # Set the search path to the minimal one used for each ts file
  SEARCH_PATH=$SEARCH_PATH_COMMON

  # Look for translations provided by Qt and QScintilla and extend the search
  # path if no existing translations are found. In this case we have to scan
  # the locally collected source files.
  if [ $xx_yy != "en_US" ]; then  # No trnaslation required for en_US
    # Look for Qt translations
    if [ "`ls $QT_LANG_DIR | grep -i qt_$xx.qm | wc -l`" -eq 0 ] &&
       [ "`ls $QT_LANG_DIR | grep -i qt_$xx_yy.qm | wc -l`" -eq 0 ]; then
       SEARCH_PATH="$SEARCH_PATH $SEARCH_PATH_QT"
echo "QT"
    fi
    # Look for QScintilla translations
    if [ "`ls $QT_LANG_DIR | grep -i qscintilla_$xx.qm | wc -l`" -eq 0 ] &&
       [ "`ls $QT_LANG_DIR | grep -i qscintilla_$xx_yy.qm | wc -l`" -eq 0 ]; then
       SEARCH_PATH="$SEARCH_PATH $SEARCH_PATH_QSCI"
echo "QSCI"
    fi
  fi
  echo
  echo

  # Do the update after user's confirmation
  echo       "$file => scan for strings in following paths"
  echo    "         => $SEARCH_PATH"
  read -p "         => Update (y/[n])? " ANS;
  ANS=${ANS:-n}
  if [ $ANS = "y" ]; then
    echo
    lupdate -qt5 -no-obsolete -locations relative $SEARCH_PATH -ts $file
  fi

done

echo