diff options
author | Filipe Azevedo <filipe.azevedo@kdab.com> | 2017-03-10 16:49:03 +0100 |
---|---|---|
committer | Volker Krause <volker.krause@kdab.com> | 2017-03-14 10:40:19 +0000 |
commit | 6207e63d7c0e79c3507f40db3f9ad54f536a7dd2 (patch) | |
tree | 00f67ac472c1c0e7bc4184bad9880388c2c2b055 | |
parent | f98a3c2764182e8dda061667ebd78fe5761a18d4 (diff) | |
download | neptune-ui-6207e63d7c0e79c3507f40db3f9ad54f536a7dd2.tar.gz |
Handle translations update and release from qmake
This deprecate usage of external scripts.
Task-number: QTAUTO-280
Change-Id: I445234cb7dd1cf573057671c73f0c57ff416421f
Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
-rw-r--r-- | apps/com.theqtcompany.i18ndemo/README | 14 | ||||
-rwxr-xr-x | apps/com.theqtcompany.i18ndemo/translations/create_qm.sh | 95 | ||||
-rwxr-xr-x | apps/com.theqtcompany.i18ndemo/translations/create_ts.sh | 98 | ||||
-rw-r--r-- | plugins/comtqci18ndemo/comtqci18ndemo.pro | 48 |
4 files changed, 50 insertions, 205 deletions
diff --git a/apps/com.theqtcompany.i18ndemo/README b/apps/com.theqtcompany.i18ndemo/README index 0296c53..cb00897 100644 --- a/apps/com.theqtcompany.i18ndemo/README +++ b/apps/com.theqtcompany.i18ndemo/README @@ -1,12 +1,4 @@ -* First time steps -Run create_qm.sh script inside translations sub-folder to generate translated files. - - * Add support for additional language -(1) Change directory to "translations" sub-folder. - -(2) Create file named "i18napp_<languageCode>.ts" - -(3) Run create_ts.sh to populate the .ts file created in step (2) above. - -(4) Edit "Languages.qml". Locate VirtualKeyboardSettings.activeLocales and add the languageCode to the existing list +(1) Edit "comtqci18ndemo.pro". Locate 'supportedLocales' and add the languageCode to the existing list. +(2) Edit "Languages.qml". Locate VirtualKeyboardSettings.activeLocales and add the languageCode to the existing list. +(3) Run "make ts" to generate/update translation catalogs. diff --git a/apps/com.theqtcompany.i18ndemo/translations/create_qm.sh b/apps/com.theqtcompany.i18ndemo/translations/create_qm.sh deleted file mode 100755 index 7983757..0000000 --- a/apps/com.theqtcompany.i18ndemo/translations/create_qm.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/sh -#**************************************************************************** -#** -#** Copyright (C) 2016 The Qt Company. -#** Contact: https://www.qt.io/licensing/ -#** -#** This file is part of the Neptune IVI UI. -#** -#** $QT_BEGIN_LICENSE:GPL-QTAS$ -#** Commercial License Usage -#** Licensees holding valid commercial Qt Automotive Suite licenses may use -#** this file in accordance with the commercial license agreement provided -#** with the Software or, alternatively, in accordance with the terms -#** contained in a written agreement between you and The Qt Company. For -#** licensing terms and conditions see https://www.qt.io/terms-conditions. -#** For further information use the contact form at https://www.qt.io/contact-us. -#** -#** GNU General Public License Usage -#** Alternatively, this file may be used under the terms of the GNU -#** General Public License version 3 or (at your option) any later version -#** approved by the KDE Free Qt Foundation. The licenses are as published by -#** the Free Software Foundation and appearing in the file LICENSE.GPL3 -#** included in the packaging of this file. Please review the following -#** information to ensure the GNU General Public License requirements will -#** be met: https://www.gnu.org/licenses/gpl-3.0.html. -#** -#** $QT_END_LICENSE$ -#** -#** SPDX-License-Identifier: GPL-3.0 -#** -#**************************************************************************** - -QTBINPATH=~/Qt/5.7/gcc_64/bin -INPUTFILESPATH=".." - -usageHelp() -{ - echo "$0" - echo "\t-h --help : Show this display usage" - echo "\t--qtdir=<path_to_qt_bin folder> : Sets path to lrelease executable" - echo "\t default value is $QTBINPATH" - echo "" -} - -while [ "$1" != "" ]; do - PARAM=`echo $1 | awk -F= '{print $1}'` - VALUE=`echo $1 | awk -F= '{print $2}'` -# echo "Param is " $PARAM -# echo "Value is " $VALUE - - case $PARAM in - -h | --help) - usageHelp - exit - ;; - --qtdir) - QTBINPATH=$VALUE - ;; - *) - echo "ERROR: unknown parameter \"$PARAM\"" - usage - exit 1 - ;; - esac - shift -done - -# TODO: If you intend to support new language, create a file as "i18napp_<langCode>.ts" -langFileList=`ls *.ts` - -# Name of the file shall match the pattern as, i18napp_<langCode> -# see the existing list above, de - german, ar - arabic, fr - french, etc. - -# TODO: Change this to match the path on your machine, if you have to -translationCommand=$QTBINPATH/lrelease - -if [ ! -f $translationCommand ]; -then - echo "Set correct path pointing to location where lrelease binary can be found" - echo "Usually it is inside <QtInstallDir>/bin folder" - echo "Uage help:" - echo - usageHelp - exit -fi - -echo -echo "List of languages translated to: " $langFileList -echo - -echo -echo "Generating translation files" -for tsFileName in $langFileList; do - $translationCommand -idbased $tsFileName -qm `basename -s .ts $tsFileName`.qm -done diff --git a/apps/com.theqtcompany.i18ndemo/translations/create_ts.sh b/apps/com.theqtcompany.i18ndemo/translations/create_ts.sh deleted file mode 100755 index e7ebb5e..0000000 --- a/apps/com.theqtcompany.i18ndemo/translations/create_ts.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/sh -#/**************************************************************************** -#** -#** Copyright (C) 2016 The Qt Company. -#** Contact: https://www.qt.io/licensing/ -#** -#** This file is part of the Neptune IVI UI. -#** -#** $QT_BEGIN_LICENSE:GPL-QTAS$ -#** Commercial License Usage -#** Licensees holding valid commercial Qt Automotive Suite licenses may use -#** this file in accordance with the commercial license agreement provided -#** with the Software or, alternatively, in accordance with the terms -#** contained in a written agreement between you and The Qt Company. For -#** licensing terms and conditions see https://www.qt.io/terms-conditions. -#** For further information use the contact form at https://www.qt.io/contact-us. -#** -#** GNU General Public License Usage -#** Alternatively, this file may be used under the terms of the GNU -#** General Public License version 3 or (at your option) any later version -#** approved by the KDE Free Qt Foundation. The licenses are as published by -#** the Free Software Foundation and appearing in the file LICENSE.GPL3 -#** included in the packaging of this file. Please review the following -#** information to ensure the GNU General Public License requirements will -#** be met: https://www.gnu.org/licenses/gpl-3.0.html. -#** -#** $QT_END_LICENSE$ -#** -#** SPDX-License-Identifier: GPL-3.0 -#** -#****************************************************************************/ - -QTBINPATH=~/Qt/5.7/gcc_64/bin -INPUTFILESPATH=".." - -usageHelp() -{ - echo "$0" - echo "\t-h --help : Show this display usage" - echo "\t--qtdir=<path_to_qt_bin folder> : Sets path to lupdate executable" - echo "\t default value is $QTBINPATH" - echo "" -} - -while [ "$1" != "" ]; do - PARAM=`echo $1 | awk -F= '{print $1}'` - VALUE=`echo $1 | awk -F= '{print $2}'` -# echo "Param is " $PARAM -# echo "Value is " $VALUE - - case $PARAM in - -h | --help) - usageHelp - exit - ;; - --qtdir) - QTBINPATH=$VALUE - ;; - *) - echo "ERROR: unknown parameter \"$PARAM\"" - usage - exit 1 - ;; - esac - shift -done - -appPrefix="i18napp_" - -# TODO: If you intend to support new language, add to this list -langFileList="en_GB fi_FI de_DE ar_AR fr_FR ko_KR ja_JP ru_RU zh_CN zh_TW" -# Name of the file shall match the pattern as, i18napp_<langCode> -# see the existing list above, de - german, ar - arabic, fr - french, etc. - -# TODO: Change this to match the path on your machine, if you have to -translationCommand=$QTBINPATH/lupdate - -if [ ! -f $translationCommand ]; -then - echo "Set correct path pointing to location where lupdate binary can be found" - echo "Usually it is inside <QtInstallDir>/bin folder" - echo "Uage help:" - echo - usageHelp - exit -fi - -inputFiles=$INPUTFILESPATH/*.qml - -echo -echo "List of languages supported are: " $langFileList -echo - -echo -echo "Generating input files for translation" -for tsFileName in $langFileList; do - $translationCommand $inputFiles -ts $appPrefix$tsFileName.ts -done diff --git a/plugins/comtqci18ndemo/comtqci18ndemo.pro b/plugins/comtqci18ndemo/comtqci18ndemo.pro index c29a44d..3f4034f 100644 --- a/plugins/comtqci18ndemo/comtqci18ndemo.pro +++ b/plugins/comtqci18ndemo/comtqci18ndemo.pro @@ -30,5 +30,51 @@ isEmpty(INSTALL_PREFIX) { qmldir.files = qmldir installPath = $$INSTALL_PREFIX/neptune/imports/shared/$$replace(uri, \\., /) qmldir.path = $$installPath + +# var, prepend, append +defineReplace(prependAll) { + for(a,$$1):result += $$2$${a}$$3 + return($$result) +} + +qmlAppPath = $$PWD/../../apps/com.theqtcompany.i18ndemo +# See qml files to scan while running lupdate/lrelease +lupdate_only { + SOURCES += $$files($$shell_quote($$shell_path($${qmlAppPath}/))*.qml, true) +} + target.path = $$installPath -INSTALLS += target qmldir + +supportedLocales = \ + ar_AR \ + de_DE \ + en_GB \ + fi_FI \ + fr_FR \ + ja_JP \ + ko_KR \ + ru_RU \ + zh_CN \ + zh_TW + +TRANSLATIONS = $$prependAll(supportedLocales, $$qmlAppPath/translations/i18napp_, .ts) + +qtPrepareTool(LUPDATE, lupdate) +qtPrepareTool(LRELEASE, lrelease) + +ts.commands = $$LUPDATE $$shell_quote($$_PRO_FILE_) +QMAKE_EXTRA_TARGETS += ts + +qm.input = TRANSLATIONS +qm.output = $$shadowed($$qmlAppPath/translations)/${QMAKE_FILE_BASE}.qm +qm.variable_out = PRE_TARGETDEPS +qm.commands = $${LRELEASE} -idbased ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT} +qm.name = LRELEASE ${QMAKE_FILE_IN} +qm.CONFIG += no_link +QMAKE_EXTRA_COMPILERS += qm + +qmfiles.files = $$prependAll(supportedLocales, $$shadowed($$qmlAppPath/translations)/i18napp_, .qm) +qmfiles.path = $$INSTALL_PREFIX/neptune/apps/com.theqtcompany.i18ndemo/translations +qmfiles.CONFIG += no_check_exist + +INSTALLS += target qmldir qmfiles |