aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2025-10-27 15:34:04 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2025-10-31 12:29:23 +0100
commit5a1610444562ed90280ff666c4474e569d87ded8 (patch)
treecb62af509aabf81923f3478fcf489abce00fb116
parent65e39a210ce4dc5bd61a490cd1bc6b17cbf706c4 (diff)
Remove qml-i18n example in qtdeclarative repo
The qml-i18n example and the qtdeclarative repo itself depend on the LinguistTools CMake package, which is not available while building qtdeclarative. This results in: - missing build coverage for the example - a cyclic dependency, because qtdeclarative depends on qttools (because of LinguistTools), and qttools depends on qtdeclarative (because of qdoc needs) - we try to find a module that will never be available, unless qtdeclarative is built together with qttools in a top-level build - in certain cases, if the top-level build fails early enough, the cyclic dependency causes reconfigurations to fail Remove the example, the lookup of LinguistTools, and the linguist doc references to avoid all these issues. Replace the qt_add_translations reference in the docs of the QQmlApplicationEngine class with a snippet copy. Pick-to: 6.8 6.10 Task-number: QTBUG-141465 Change-Id: Id88603a3753f53dfac9f350e981073effda15eb1 Reviewed-by: Masoud Jami <masoud.jami@qt.io>
-rw-r--r--CMakeLists.txt2
-rw-r--r--examples/qml/CMakeLists.txt6
-rw-r--r--examples/qml/qml-i18n/CMakeLists.txt47
-rw-r--r--examples/qml/qml-i18n/Main.qml25
-rw-r--r--examples/qml/qml-i18n/doc/images/qml-i18n-example.pngbin1945 -> 0 bytes
-rw-r--r--examples/qml/qml-i18n/doc/src/i18n.qdoc61
-rw-r--r--examples/qml/qml-i18n/i18n/base.ts12
-rw-r--r--examples/qml/qml-i18n/i18n/qml_en.ts4
-rw-r--r--examples/qml/qml-i18n/i18n/qml_en_AU.ts12
-rw-r--r--examples/qml/qml-i18n/i18n/qml_fr.ts12
-rw-r--r--examples/qml/qml-i18n/main.cpp18
-rw-r--r--examples/qml/qml-i18n/qml-i18n.pro18
-rw-r--r--examples/qml/qml-i18n/qml-i18n.qmlproject16
-rw-r--r--examples/qml/qml-i18n/qml-i18n.qrc6
-rw-r--r--examples/qml/qml-i18n/qmldir5
-rw-r--r--examples/qml/qml.pro3
-rw-r--r--src/qml/doc/qtqml.qdocconf1
-rw-r--r--src/qml/doc/snippets/cmake/qt_add_translations.cmake7
-rw-r--r--src/qml/qml/qqmlapplicationengine.cpp2
-rw-r--r--src/qmlcompiler/doc/qtqmlcompiler.qdocconf1
-rw-r--r--src/quick/doc/qtquick.qdocconf1
21 files changed, 9 insertions, 250 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e296507868..60440aa0e1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,7 +20,7 @@ find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals)
qt_internal_project_setup()
find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED Core)
-find_package(Qt6 ${PROJECT_VERSION} QUIET CONFIG OPTIONAL_COMPONENTS Gui Network Widgets OpenGL OpenGLWidgets Sql Concurrent Test TestInternalsPrivate LanguageServerPrivate LinguistTools Svg)
+find_package(Qt6 ${PROJECT_VERSION} QUIET CONFIG OPTIONAL_COMPONENTS Gui Network Widgets OpenGL OpenGLWidgets Sql Concurrent Test TestInternalsPrivate LanguageServerPrivate Svg)
# Set up QT_HOST_PATH as an extra root path to look for the ShaderToolsTools package
# when cross-compiling.
diff --git a/examples/qml/CMakeLists.txt b/examples/qml/CMakeLists.txt
index e5dc00d0fd..ee5ac0b589 100644
--- a/examples/qml/CMakeLists.txt
+++ b/examples/qml/CMakeLists.txt
@@ -2,9 +2,3 @@
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
add_subdirectory(tutorials)
-if(TARGET Qt6::Quick)
- if (TARGET Qt6::lupdate)
- qt_internal_add_example(qml-i18n)
- endif()
-endif()
-
diff --git a/examples/qml/qml-i18n/CMakeLists.txt b/examples/qml/qml-i18n/CMakeLists.txt
deleted file mode 100644
index 00e143d348..0000000000
--- a/examples/qml/qml-i18n/CMakeLists.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright (C) 2024 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(qml-i18n LANGUAGES CXX)
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick Qml LinguistTools)
-
-qt_standard_project_setup(REQUIRES 6.8 I18N_TRANSLATED_LANGUAGES en en_AU fr)
-
-qt_add_executable(qmli18n WIN32 MACOSX_BUNDLE main.cpp)
-
-target_link_libraries(qmli18n PRIVATE
- Qt6::Core
- Qt6::Gui
- Qt6::Qml
- Qt6::Quick
-)
-
-qt_add_qml_module(qmli18n
- URI Translated
- QML_FILES
- Main.qml
-)
-
-#![0]
-qt_add_translations(qmli18n
- RESOURCE_PREFIX /qt/qml/Translated/i18n
- TS_FILE_BASE qml
- TS_FILE_DIR i18n
-)
-#![0]
-
-install(TARGETS qmli18n
- BUNDLE DESTINATION .
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-)
-
-qt_generate_deploy_qml_app_script(
- TARGET qmli18n
- OUTPUT_SCRIPT deploy_script
- MACOS_BUNDLE_POST_BUILD
- NO_UNSUPPORTED_PLATFORM_ERROR
- DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
-)
-install(SCRIPT ${deploy_script})
diff --git a/examples/qml/qml-i18n/Main.qml b/examples/qml/qml-i18n/Main.qml
deleted file mode 100644
index 8d414348dd..0000000000
--- a/examples/qml/qml-i18n/Main.qml
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import QtQuick
-import QtQuick.Window
-
-Window {
- visible: true
- width: 640; height: 480
-
- Column {
- anchors.fill: parent; spacing: 20
-
- Text {
- text: "If a translation is available for the system language (eg. French) then the " +
- "string below will be translated (eg. 'Bonjour'). Otherwise it will show 'Hello'."
- width: parent.width; wrapMode: Text.WordWrap
- }
-
- Text {
- text: qsTr("Hello")
- font.pointSize: 25; anchors.horizontalCenter: parent.horizontalCenter
- }
- }
-}
diff --git a/examples/qml/qml-i18n/doc/images/qml-i18n-example.png b/examples/qml/qml-i18n/doc/images/qml-i18n-example.png
deleted file mode 100644
index 02f645e702..0000000000
--- a/examples/qml/qml-i18n/doc/images/qml-i18n-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/qml/qml-i18n/doc/src/i18n.qdoc b/examples/qml/qml-i18n/doc/src/i18n.qdoc
deleted file mode 100644
index 900c6b61de..0000000000
--- a/examples/qml/qml-i18n/doc/src/i18n.qdoc
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (C) 2023 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-/*!
- \title Qt Quick I18N
- \examplecategory {User Interface Components}
- \example qml-i18n
- \ingroup examples-linguist
- \brief Generating translation files (TS and QM) for a Qt Quick application.
-
- When you run the example application, the QML runtime automatically loads a
- translation from the \c i18n subdirectory of the directory that contains the
- main .qml file, based on the system language.
-
- \section1 Marking Text as Translatable
-
- In the \c Main.qml file, use the \c qsTr command to mark UI text as
- translatable:
-
- \quotefromfile qml-i18n/Main.qml
- \skipto }
- \skipto Text
- \printuntil )
-
- \section1 Enabling Translation
-
- In the \c main.cpp file, use \l QQmlApplicationEngine to automatically load
- translation files from a subdirectory called \c i18n in the directory that
- contains the main QML file:
-
- \quotefromfile qml-i18n/main.cpp
- \skipto <QQmlApplicationEngine>
- \printuntil engine;
-
- The translation file names in the \c i18n subdirectory must have the prefix
- \c qml_. For example, \c qml_en_AU.ts.
-
- \section1 Creating Translation Files
-
- Add the \c LinguistTools module as a value of the \c find_package command in
- the \c CMakeLists.txt file:
-
- \quotefromfile qml-i18n/CMakeLists.txt
- \skipto find_package(
- \printuntil )
-
- Define the translation files to generate in the \l qt_add_translations
- command:
-
- \skipto qt_add_translations
- \printuntil )
-
- Build the application to generate TS and QM files.
-
- \note On Android, make sure to include the QM files as resources.
-
- \section1 Adding Translations
-
- To create translations for new languages, copy \e {i18n/base.ts} to
- \e {i18n/qml_<lang>.ts}. You can use \l{Qt Linguist} to translate the
- strings.
-*/
diff --git a/examples/qml/qml-i18n/i18n/base.ts b/examples/qml/qml-i18n/i18n/base.ts
deleted file mode 100644
index 17564620e3..0000000000
--- a/examples/qml/qml-i18n/i18n/base.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS>
-<TS version="2.1" sourcelanguage="en">
-<context>
- <name>Main</name>
- <message>
- <location filename="../Main.qml" line="21"/>
- <source>Hello</source>
- <translation type="unfinished"></translation>
- </message>
-</context>
-</TS>
diff --git a/examples/qml/qml-i18n/i18n/qml_en.ts b/examples/qml/qml-i18n/i18n/qml_en.ts
deleted file mode 100644
index eb9b75f7bf..0000000000
--- a/examples/qml/qml-i18n/i18n/qml_en.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS>
-<TS version="2.1" language="en" sourcelanguage="en">
-</TS>
diff --git a/examples/qml/qml-i18n/i18n/qml_en_AU.ts b/examples/qml/qml-i18n/i18n/qml_en_AU.ts
deleted file mode 100644
index 98e1d8649f..0000000000
--- a/examples/qml/qml-i18n/i18n/qml_en_AU.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS>
-<TS version="2.1" language="en_AU" sourcelanguage="en">
-<context>
- <name>Main</name>
- <message>
- <location filename="../Main.qml" line="21"/>
- <source>Hello</source>
- <translation>G&apos;day</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/qml/qml-i18n/i18n/qml_fr.ts b/examples/qml/qml-i18n/i18n/qml_fr.ts
deleted file mode 100644
index 73c525e535..0000000000
--- a/examples/qml/qml-i18n/i18n/qml_fr.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS>
-<TS version="2.1" language="fr" sourcelanguage="en">
-<context>
- <name>Main</name>
- <message>
- <location filename="../Main.qml" line="21"/>
- <source>Hello</source>
- <translation>Bonjour</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/qml/qml-i18n/main.cpp b/examples/qml/qml-i18n/main.cpp
deleted file mode 100644
index fe20802d3d..0000000000
--- a/examples/qml/qml-i18n/main.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (C) 2024 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QGuiApplication>
-#include <QQmlApplicationEngine>
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
- QQmlApplicationEngine engine;
-
- 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
deleted file mode 100644
index 0ecfbc01e5..0000000000
--- a/examples/qml/qml-i18n/qml-i18n.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-TEMPLATE = app
-
-QT += quick qml
-SOURCES += main.cpp
-
-RESOURCES += qml-i18n.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/qml/qml-i18n
-INSTALLS += target
-
-QM_FILES_RESOURCE_PREFIX = /qt/qml/Translated/i18n/
-CONFIG += lrelease embed_translations
-
-TRANSLATIONS += \
- i18n/base.ts \
- i18n/qml_en.ts \
- i18n/qml_en_AU.ts \
- i18n/qml_fr.ts
diff --git a/examples/qml/qml-i18n/qml-i18n.qmlproject b/examples/qml/qml-i18n/qml-i18n.qmlproject
deleted file mode 100644
index a1a56c2bb2..0000000000
--- a/examples/qml/qml-i18n/qml-i18n.qmlproject
+++ /dev/null
@@ -1,16 +0,0 @@
-import QmlProject 1.1
-
-Project {
- mainFile: "qml-i18n.qml"
-
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
-}
diff --git a/examples/qml/qml-i18n/qml-i18n.qrc b/examples/qml/qml-i18n/qml-i18n.qrc
deleted file mode 100644
index 79ec649894..0000000000
--- a/examples/qml/qml-i18n/qml-i18n.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<RCC>
- <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
deleted file mode 100644
index b4773af30e..0000000000
--- a/examples/qml/qml-i18n/qmldir
+++ /dev/null
@@ -1,5 +0,0 @@
-module Translated
-typeinfo qml-i18n.qmltypes
-depends QtQuick
-prefer :/qt/qml/Translated/
-Main 254.0 Main.qml
diff --git a/examples/qml/qml.pro b/examples/qml/qml.pro
index f1652820a6..45abc2bf8f 100644
--- a/examples/qml/qml.pro
+++ b/examples/qml/qml.pro
@@ -3,6 +3,3 @@ QT_FOR_CONFIG += qml
SUBDIRS += \
tutorials
-
-EXAMPLE_FILES = \
- qml-i18n
diff --git a/src/qml/doc/qtqml.qdocconf b/src/qml/doc/qtqml.qdocconf
index f5b66743e4..1a235e4771 100644
--- a/src/qml/doc/qtqml.qdocconf
+++ b/src/qml/doc/qtqml.qdocconf
@@ -40,7 +40,6 @@ depends += \
qtgui \
qtquick \
qtdoc \
- qtlinguist \
qtwidgets \
qtquickcontrols \
qmake \
diff --git a/src/qml/doc/snippets/cmake/qt_add_translations.cmake b/src/qml/doc/snippets/cmake/qt_add_translations.cmake
new file mode 100644
index 0000000000..4820a2ec6b
--- /dev/null
+++ b/src/qml/doc/snippets/cmake/qt_add_translations.cmake
@@ -0,0 +1,7 @@
+#![0]
+qt_add_translations(App
+ RESOURCE_PREFIX /qt/qml/Translated/i18n
+ TS_FILE_BASE qml
+ TS_FILE_DIR i18n
+)
+#![0]
diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp
index 108312a859..c6e6716af6 100644
--- a/src/qml/qml/qqmlapplicationengine.cpp
+++ b/src/qml/qml/qqmlapplicationengine.cpp
@@ -249,7 +249,7 @@ void QQmlApplicationEnginePrivate::updateTranslationDirectory(const QUrl &url)
needs to include the resource prefix of the main file's QML module
(\e{/qt/qml} by default) and the module URI. For example, to provide
translation files for a module called "Translated":
- \snippet qml-i18n/CMakeLists.txt 0
+ \snippet cmake/qt_add_translations.cmake 0
*/
/*!
diff --git a/src/qmlcompiler/doc/qtqmlcompiler.qdocconf b/src/qmlcompiler/doc/qtqmlcompiler.qdocconf
index b21cdee9f5..fa1a7d1458 100644
--- a/src/qmlcompiler/doc/qtqmlcompiler.qdocconf
+++ b/src/qmlcompiler/doc/qtqmlcompiler.qdocconf
@@ -33,7 +33,6 @@ depends += \
qtgui \
qtquick \
qtdoc \
- qtlinguist \
qtwidgets \
qtquickcontrols \
qmake \
diff --git a/src/quick/doc/qtquick.qdocconf b/src/quick/doc/qtquick.qdocconf
index 807b44ec6e..872428ed8f 100644
--- a/src/quick/doc/qtquick.qdocconf
+++ b/src/quick/doc/qtquick.qdocconf
@@ -51,7 +51,6 @@ depends += \
qtqmltest \
qtqmlcore \
qtgui \
- qtlinguist \
qtlottie \
qtquickcontrols \
qtquick3d \