From 24776bfcf6f0c098edf03039895b627b0c3599e8 Mon Sep 17 00:00:00 2001 From: Andre Rummler Date: Mon, 21 Sep 2026 12:40:52 +0200 Subject: [PATCH] Avoid setting globally QLocale which was introduced in a recent MR as it will change number formats, etc. which is not necessarily what a user switching language wants. Beside that small fix of a trasnlation comment. --- sources/elementtextsmover.cpp | 3 ++- sources/qet.cpp | 19 ++++++++++--------- sources/qetapp.cpp | 4 +++- sources/qetapp.h | 3 +++ sources/undocommand/rotatetextscommand.cpp | 2 +- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/sources/elementtextsmover.cpp b/sources/elementtextsmover.cpp index 16026a112..ddf2f235c 100644 --- a/sources/elementtextsmover.cpp +++ b/sources/elementtextsmover.cpp @@ -19,6 +19,7 @@ #include "QPropertyUndoCommand/qpropertyundocommand.h" #include "diagram.h" +#include "qetapp.h" #include "qetgraphicsitem/dynamicelementtextitem.h" #include "qetgraphicsitem/elementtextitemgroup.h" @@ -146,5 +147,5 @@ QString ElementTextsMover::undoText() const if (parts.isEmpty()) return QString(); // should never occur - return QObject::tr("Déplacer %1").arg(QLocale().createSeparatedList(parts)); + return QObject::tr("Déplacer %1").arg(QLocale(QETApp::interfaceLanguage()).createSeparatedList(parts)); } diff --git a/sources/qet.cpp b/sources/qet.cpp index e6a05afad..060bce7b2 100644 --- a/sources/qet.cpp +++ b/sources/qet.cpp @@ -16,6 +16,7 @@ along with QElectroTech. If not, see . */ #include "qet.h" +#include "qetapp.h" #include "qeticons.h" #include "shortcutmanager.h" @@ -276,7 +277,7 @@ QString QET::ElementsAndConductorsSentence( parts.append( QObject::tr( "%n élément(s)", - "part of a enumerative partial sentence listing the content of a diagram", + "Sentence fragment used in an automatically generated list of different objects, e.g. objects moved at the same time, which will be combined into a sentence.", elements_count ) ); @@ -286,7 +287,7 @@ QString QET::ElementsAndConductorsSentence( parts.append( QObject::tr( "%n conducteur(s)", - "part of a enumerative partial sentence listing the content of a diagram", + "Sentence fragment used in an automatically generated list of different objects, e.g. objects moved at the same time, which will be combined into a sentence.", conductors_count ) ); @@ -296,7 +297,7 @@ QString QET::ElementsAndConductorsSentence( parts.append( QObject::tr( "%n champ(s) de texte", - "part of a enumerative partial sentence listing the content of a diagram", + "Sentence fragment used in an automatically generated list of different objects, e.g. objects moved at the same time, which will be combined into a sentence.", texts_count ) ); @@ -306,7 +307,7 @@ QString QET::ElementsAndConductorsSentence( parts.append( QObject::tr( "%n image(s)", - "part of a enumerative partial sentence listing the content of a diagram", + "Sentence fragment used in an automatically generated list of different objects, e.g. objects moved at the same time, which will be combined into a sentence.", images_count ) ); @@ -316,7 +317,7 @@ QString QET::ElementsAndConductorsSentence( parts.append( QObject::tr( "%n forme(s)", - "part of a enumerative partial sentence listing the content of a diagram", + "Sentence fragment used in an automatically generated list of different objects, e.g. objects moved at the same time, which will be combined into a sentence.", shapes_count ) ); @@ -326,7 +327,7 @@ QString QET::ElementsAndConductorsSentence( parts.append( QObject::tr( "%n texte(s) d'élément", - "part of a enumerative partial sentence listing the content of a diagram", + "Sentence fragment used in an automatically generated list of different objects, e.g. objects moved at the same time, which will be combined into a sentence.", element_text_count ) ); @@ -336,7 +337,7 @@ QString QET::ElementsAndConductorsSentence( parts.append( QObject::tr( "%n tableau(s)", - "part of a enumerative partial sentence listing the content of diagram", + "Sentence fragment used in an automatically generated list of different objects, e.g. objects moved at the same time, which will be combined into a sentence.", tables_count ) ); @@ -346,13 +347,13 @@ QString QET::ElementsAndConductorsSentence( parts.append( QObject::tr( "%n plan(s) de bornes", - "part of a enumerative partial sentence listing the content of a diagram", + "Sentence fragment used in an automatically generated list of different objects, e.g. objects moved at the same time, which will be combined into a sentence.", terminal_strip_count ) ); } - return QLocale().createSeparatedList(parts); + return QLocale(QETApp::interfaceLanguage()).createSeparatedList(parts); } /** diff --git a/sources/qetapp.cpp b/sources/qetapp.cpp index f24aade63..f66c3be74 100644 --- a/sources/qetapp.cpp +++ b/sources/qetapp.cpp @@ -236,7 +236,7 @@ QString QETApp::loadedQtTranslationFile() void QETApp::setLanguage(const QString &desired_language) { QString languages_path = languagesPath(); - QLocale::setDefault(QLocale(desired_language)); + m_interface_language = desired_language; // load Qt library translations QString qt_l10n_path = QLibraryInfo::path(QLibraryInfo::TranslationsPath); @@ -3045,3 +3045,5 @@ int QETApp::projectId(const QETProject *project) { } return(-1); } + +QString QETApp::m_interface_language; diff --git a/sources/qetapp.h b/sources/qetapp.h index ad249fd84..e0ee13a03 100644 --- a/sources/qetapp.h +++ b/sources/qetapp.h @@ -68,6 +68,7 @@ class QETApp : public QObject public: static QETApp *instance(); void setLanguage(const QString &); + static QString interfaceLanguage() { return m_interface_language; } static QString langFromSetting (); void switchLayout(Qt::LayoutDirection); static void printHelp(); @@ -246,6 +247,8 @@ class QETApp : public QObject static QString m_user_company_tbt_dir; static QString m_user_custom_tbt_dir; static QString m_user_macros_dir; + + static QString m_interface_language; public slots: void systray(QSystemTrayIcon::ActivationReason); diff --git a/sources/undocommand/rotatetextscommand.cpp b/sources/undocommand/rotatetextscommand.cpp index 33a2dde8b..5b19dedac 100644 --- a/sources/undocommand/rotatetextscommand.cpp +++ b/sources/undocommand/rotatetextscommand.cpp @@ -60,7 +60,7 @@ m_diagram(diagram) parts << QObject::tr("%n texte(s)", "", texts_list.count()); if (groups_list.count()) parts << QObject::tr("%n groupe(s) de textes", "", groups_list.count()); - setText(QObject::tr("Pivoter %1").arg(QLocale().createSeparatedList(parts))); + setText(QObject::tr("Pivoter %1").arg(QLocale(QETApp::interfaceLanguage()).createSeparatedList(parts))); for(DiagramTextItem *dti : texts_list) setupAnimation(dti, "rotation", dti->rotation(), m_rotation);