From ad3bf77ff0f599594b417da8d437501c44410987 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Fri, 10 Sep 2021 02:35:52 -0400 Subject: [PATCH] add test case for qrc translations --- test cases/frameworks/4 qt/main.cpp | 9 +++++++++ test cases/frameworks/4 qt/meson.build | 6 ++++++ test cases/frameworks/4 qt/qt4_lang.qrc | 6 ++++++ test cases/frameworks/4 qt/qt4embedded_fr.ts | 12 ++++++++++++ test cases/frameworks/4 qt/qt5_lang.qrc | 6 ++++++ test cases/frameworks/4 qt/qt5embedded_fr.ts | 12 ++++++++++++ 6 files changed, 51 insertions(+) create mode 100644 test cases/frameworks/4 qt/qt4_lang.qrc create mode 100644 test cases/frameworks/4 qt/qt4embedded_fr.ts create mode 100644 test cases/frameworks/4 qt/qt5_lang.qrc create mode 100644 test cases/frameworks/4 qt/qt5embedded_fr.ts diff --git a/test cases/frameworks/4 qt/main.cpp b/test cases/frameworks/4 qt/main.cpp index de00b15dc..3c141b9d2 100644 --- a/test cases/frameworks/4 qt/main.cpp +++ b/test cases/frameworks/4 qt/main.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include "mainWindow.h" #if QT_VERSION > 0x050000 @@ -16,6 +18,13 @@ int main(int argc, char **argv) { Q_INIT_RESOURCE(stuff2); #endif QApplication app(argc, argv); + + auto *translator = new QTranslator; + if (translator->load(QLocale(), QT "embedded", "_", ":/lang")) + qApp->installTranslator(translator); + + qDebug() << QObject::tr("Translate me!"); + MainWindow *win = new MainWindow(); QImage qi(":/thing.png"); if(qi.width() != 640) { diff --git a/test cases/frameworks/4 qt/meson.build b/test cases/frameworks/4 qt/meson.build index 2ec582581..163059334 100644 --- a/test cases/frameworks/4 qt/meson.build +++ b/test cases/frameworks/4 qt/meson.build @@ -81,10 +81,16 @@ foreach qt : ['qt4', 'qt5', 'qt6'] # qt4-rcc and qt5-rcc take different arguments, for example qt4: ['-compress', '3']; qt5: '--compress=3' qtmodule.preprocess(qt + 'testrccarg', qresources : files(['stuff.qrc', 'stuff2.qrc']), rcc_extra_arguments : '--compress=3', method : get_option('method')) + translations_cpp = qtmodule.compile_translations(qresource: qt+'_lang.qrc') + # unity builds suck and definitely cannot handle two qrc embeds in one compilation unit + unityproof_translations = static_library('unityproof_translations', translations_cpp) + + extra_cpp_args += '-DQT="@0@"'.format(qt) qexe = executable(qt + 'app', sources : ['main.cpp', 'mainWindow.cpp', # Sources that don't need preprocessing. prep, prep_rcc], dependencies : qtdep, + link_with: unityproof_translations, cpp_args: extra_cpp_args, gui_app : true) diff --git a/test cases/frameworks/4 qt/qt4_lang.qrc b/test cases/frameworks/4 qt/qt4_lang.qrc new file mode 100644 index 000000000..a6d2b5472 --- /dev/null +++ b/test cases/frameworks/4 qt/qt4_lang.qrc @@ -0,0 +1,6 @@ + + + qt4embedded_fr.qm + + + diff --git a/test cases/frameworks/4 qt/qt4embedded_fr.ts b/test cases/frameworks/4 qt/qt4embedded_fr.ts new file mode 100644 index 000000000..0638bd5e9 --- /dev/null +++ b/test cases/frameworks/4 qt/qt4embedded_fr.ts @@ -0,0 +1,12 @@ + + + + + QObject + + + Translate me! + Traduisez moi! + + + diff --git a/test cases/frameworks/4 qt/qt5_lang.qrc b/test cases/frameworks/4 qt/qt5_lang.qrc new file mode 100644 index 000000000..cf4ddc600 --- /dev/null +++ b/test cases/frameworks/4 qt/qt5_lang.qrc @@ -0,0 +1,6 @@ + + + qt5embedded_fr.qm + + + diff --git a/test cases/frameworks/4 qt/qt5embedded_fr.ts b/test cases/frameworks/4 qt/qt5embedded_fr.ts new file mode 100644 index 000000000..4e3116bcf --- /dev/null +++ b/test cases/frameworks/4 qt/qt5embedded_fr.ts @@ -0,0 +1,12 @@ + + + + + QObject + + + Translate me! + Traduisez moi! + + +