aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier De Cannière <[email protected]>2024-04-03 16:12:08 +0200
committerOlivier De Cannière <[email protected]>2024-04-04 10:46:13 +0200
commita8f6a298ae989c2569433d3607f9f696b2dbac93 (patch)
tree925ab9fdd7c8af1c94a932eb393abb737cd248ed
parentbb7ba7667b4cf3565aa1849d08cc71b9ac011e77 (diff)
Examples: Port the i18n example to loadFromModule
Change-Id: I81946dc3e1c23f0a0f2eaad866deff652a7c0563 Reviewed-by: Ulf Hermann <[email protected]>
-rw-r--r--examples/qml/qml-i18n/CMakeLists.txt8
-rw-r--r--examples/qml/qml-i18n/Main.qml (renamed from examples/qml/qml-i18n/qml-i18n.qml)0
-rw-r--r--examples/qml/qml-i18n/doc/src/i18n.qdoc4
-rw-r--r--examples/qml/qml-i18n/i18n/base.ts4
-rw-r--r--examples/qml/qml-i18n/i18n/qml_en_AU.ts4
-rw-r--r--examples/qml/qml-i18n/i18n/qml_fr.ts4
-rw-r--r--examples/qml/qml-i18n/main.cpp14
-rw-r--r--examples/qml/qml-i18n/qml-i18n.pro2
-rw-r--r--examples/qml/qml-i18n/qml-i18n.qrc5
-rw-r--r--examples/qml/qml-i18n/qmldir5
10 files changed, 27 insertions, 23 deletions
diff --git a/examples/qml/qml-i18n/CMakeLists.txt b/examples/qml/qml-i18n/CMakeLists.txt
index 2a59ebcd53..fd242d3678 100644
--- a/examples/qml/qml-i18n/CMakeLists.txt
+++ b/examples/qml/qml-i18n/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2022 The Qt Company Ltd.
+# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
@@ -18,13 +18,13 @@ target_link_libraries(qmli18n PRIVATE
)
qt_add_qml_module(qmli18n
- URI translated
+ URI Translated
QML_FILES
- qml-i18n.qml
+ Main.qml
)
qt_add_translations(qmli18n
- RESOURCE_PREFIX /qt/qml/translated/i18n
+ RESOURCE_PREFIX /qt/qml/Translated/i18n
TS_FILE_BASE qml
TS_FILE_DIR i18n
)
diff --git a/examples/qml/qml-i18n/qml-i18n.qml b/examples/qml/qml-i18n/Main.qml
index 8d414348dd..8d414348dd 100644
--- a/examples/qml/qml-i18n/qml-i18n.qml
+++ b/examples/qml/qml-i18n/Main.qml
diff --git a/examples/qml/qml-i18n/doc/src/i18n.qdoc b/examples/qml/qml-i18n/doc/src/i18n.qdoc
index ec778293d5..6096aa3383 100644
--- a/examples/qml/qml-i18n/doc/src/i18n.qdoc
+++ b/examples/qml/qml-i18n/doc/src/i18n.qdoc
@@ -14,10 +14,10 @@
\section1 Marking Text as Translatable
- In the \c qml-i18n.qml file, use the \c qsTr command to mark UI text as
+ In the \c Main.qml file, use the \c qsTr command to mark UI text as
translatable:
- \quotefromfile qml-i18n/qml-i18n.qml
+ \quotefromfile qml-i18n/Main.qml
\skipto }
\skipto Text
\printuntil )
diff --git a/examples/qml/qml-i18n/i18n/base.ts b/examples/qml/qml-i18n/i18n/base.ts
index 99ceeeb016..17564620e3 100644
--- a/examples/qml/qml-i18n/i18n/base.ts
+++ b/examples/qml/qml-i18n/i18n/base.ts
@@ -2,9 +2,9 @@
<!DOCTYPE TS>
<TS version="2.1" sourcelanguage="en">
<context>
- <name>qml-i18n</name>
+ <name>Main</name>
<message>
- <location filename="../qml-i18n.qml" line="68"/>
+ <location filename="../Main.qml" line="21"/>
<source>Hello</source>
<translation type="unfinished"></translation>
</message>
diff --git a/examples/qml/qml-i18n/i18n/qml_en_AU.ts b/examples/qml/qml-i18n/i18n/qml_en_AU.ts
index feb4f9e9c0..98e1d8649f 100644
--- a/examples/qml/qml-i18n/i18n/qml_en_AU.ts
+++ b/examples/qml/qml-i18n/i18n/qml_en_AU.ts
@@ -2,9 +2,9 @@
<!DOCTYPE TS>
<TS version="2.1" language="en_AU" sourcelanguage="en">
<context>
- <name>qml-i18n</name>
+ <name>Main</name>
<message>
- <location filename="../qml-i18n.qml" line="68"/>
+ <location filename="../Main.qml" line="21"/>
<source>Hello</source>
<translation>G&apos;day</translation>
</message>
diff --git a/examples/qml/qml-i18n/i18n/qml_fr.ts b/examples/qml/qml-i18n/i18n/qml_fr.ts
index c4872e63d0..73c525e535 100644
--- a/examples/qml/qml-i18n/i18n/qml_fr.ts
+++ b/examples/qml/qml-i18n/i18n/qml_fr.ts
@@ -2,9 +2,9 @@
<!DOCTYPE TS>
<TS version="2.1" language="fr" sourcelanguage="en">
<context>
- <name>qml-i18n</name>
+ <name>Main</name>
<message>
- <location filename="../qml-i18n.qml" line="68"/>
+ <location filename="../Main.qml" line="21"/>
<source>Hello</source>
<translation>Bonjour</translation>
</message>
diff --git a/examples/qml/qml-i18n/main.cpp b/examples/qml/qml-i18n/main.cpp
index fd38bd3856..fe20802d3d 100644
--- a/examples/qml/qml-i18n/main.cpp
+++ b/examples/qml/qml-i18n/main.cpp
@@ -1,5 +1,6 @@
-// Copyright (C) 2020 The Qt Company Ltd.
+// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
#include <QGuiApplication>
#include <QQmlApplicationEngine>
@@ -7,14 +8,11 @@ int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
- const QUrl url(QStringLiteral("qrc:/qt/qml/translated/qml-i18n.qml"));
- QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
- &app, [url](QObject *obj, const QUrl &objUrl) {
- if (!obj && url == objUrl)
- QCoreApplication::exit(-1);
- }, Qt::QueuedConnection);
- engine.load(url);
+ QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
+ &app, []() { QCoreApplication::exit(-1); },
+ Qt::QueuedConnection);
+ engine.loadFromModule("Translated", "Main");
return app.exec();
}
diff --git a/examples/qml/qml-i18n/qml-i18n.pro b/examples/qml/qml-i18n/qml-i18n.pro
index a69f370afc..0ecfbc01e5 100644
--- a/examples/qml/qml-i18n/qml-i18n.pro
+++ b/examples/qml/qml-i18n/qml-i18n.pro
@@ -8,7 +8,7 @@ RESOURCES += qml-i18n.qrc
target.path = $$[QT_INSTALL_EXAMPLES]/qml/qml-i18n
INSTALLS += target
-QM_FILES_RESOURCE_PREFIX = /qt/qml/translated/i18n/
+QM_FILES_RESOURCE_PREFIX = /qt/qml/Translated/i18n/
CONFIG += lrelease embed_translations
TRANSLATIONS += \
diff --git a/examples/qml/qml-i18n/qml-i18n.qrc b/examples/qml/qml-i18n/qml-i18n.qrc
index 94a8d32d64..79ec649894 100644
--- a/examples/qml/qml-i18n/qml-i18n.qrc
+++ b/examples/qml/qml-i18n/qml-i18n.qrc
@@ -1,5 +1,6 @@
<RCC>
- <qresource prefix="/qt/qml/translated">
- <file>qml-i18n.qml</file>
+ <qresource prefix="/qt/qml/Translated">
+ <file>Main.qml</file>
+ <file>qmldir</file>
</qresource>
</RCC>
diff --git a/examples/qml/qml-i18n/qmldir b/examples/qml/qml-i18n/qmldir
new file mode 100644
index 0000000000..b4773af30e
--- /dev/null
+++ b/examples/qml/qml-i18n/qmldir
@@ -0,0 +1,5 @@
+module Translated
+typeinfo qml-i18n.qmltypes
+depends QtQuick
+prefer :/qt/qml/Translated/
+Main 254.0 Main.qml