Compare commits

..

1 Commits

Author SHA1 Message Date
Mentalflow 1ca1d72f92
Project: Add multilingual support. 2025-05-18 16:20:40 +08:00
8 changed files with 25 additions and 38 deletions

View File

@ -1,7 +1,6 @@
import QtQuick 2.15
import QtQuick.Layouts 1.11
import QtQuick.Controls 2.15
import QtQuick.Window 2.15
import RibbonUI 1.1
RibbonTabBar {

View File

@ -29,25 +29,25 @@
</message>
<message>
<location filename="../qml/Qt5/RibbonBackStageView.qml" line="482"/>
<location filename="../qml/Qt6/RibbonBackStageView.qml" line="482"/>
<location filename="../qml/Qt6/RibbonBackStageView.qml" line="476"/>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Qt5/RibbonBackStageView.qml" line="493"/>
<location filename="../qml/Qt6/RibbonBackStageView.qml" line="493"/>
<location filename="../qml/Qt6/RibbonBackStageView.qml" line="487"/>
<source>Minimize</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Qt5/RibbonBackStageView.qml" line="504"/>
<location filename="../qml/Qt6/RibbonBackStageView.qml" line="504"/>
<location filename="../qml/Qt6/RibbonBackStageView.qml" line="498"/>
<source>Restore</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Qt5/RibbonBackStageView.qml" line="504"/>
<location filename="../qml/Qt6/RibbonBackStageView.qml" line="504"/>
<location filename="../qml/Qt6/RibbonBackStageView.qml" line="498"/>
<source>Maximize</source>
<translation type="unfinished"></translation>
</message>
@ -114,14 +114,6 @@
</context>
<context>
<name>RibbonMessageBarGroup</name>
<message>
<location filename="../qml/Qt5/RibbonMessageBarGroup.qml" line="102"/>
<location filename="../qml/Qt5/RibbonMessageBarGroup.qml" line="111"/>
<location filename="../qml/Qt6/RibbonMessageBarGroup.qml" line="102"/>
<location filename="../qml/Qt6/RibbonMessageBarGroup.qml" line="111"/>
<source>&apos;s </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Qt5/RibbonMessageBarGroup.qml" line="180"/>
<location filename="../qml/Qt6/RibbonMessageBarGroup.qml" line="180"/>
@ -202,7 +194,7 @@
</message>
<message>
<location filename="../qml/Qt5/RibbonTabBar.qml" line="302"/>
<location filename="../qml/Qt6/RibbonTabBar.qml" line="302"/>
<location filename="../qml/Qt6/RibbonTabBar.qml" line="301"/>
<source>RibbonTabBar: Error loading component:</source>
<translation type="unfinished"></translation>
</message>
@ -352,31 +344,31 @@
<name>RibbonWindow</name>
<message>
<location filename="../qml/Qt5/RibbonWindow.qml" line="148"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="148"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="149"/>
<source>Quit</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Qt5/RibbonWindow.qml" line="149"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="149"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="150"/>
<source>Minimize</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Qt5/RibbonWindow.qml" line="150"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="150"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="151"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Qt5/RibbonWindow.qml" line="151"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="151"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="152"/>
<source>Do you want to close this window?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Qt5/RibbonWindow.qml" line="152"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="152"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="153"/>
<source>Please note</source>
<translation type="unfinished"></translation>
</message>

View File

@ -29,25 +29,25 @@
</message>
<message>
<location filename="../qml/Qt5/RibbonBackStageView.qml" line="482"/>
<location filename="../qml/Qt6/RibbonBackStageView.qml" line="482"/>
<location filename="../qml/Qt6/RibbonBackStageView.qml" line="476"/>
<source>Close</source>
<translation></translation>
</message>
<message>
<location filename="../qml/Qt5/RibbonBackStageView.qml" line="493"/>
<location filename="../qml/Qt6/RibbonBackStageView.qml" line="493"/>
<location filename="../qml/Qt6/RibbonBackStageView.qml" line="487"/>
<source>Minimize</source>
<translation></translation>
</message>
<message>
<location filename="../qml/Qt5/RibbonBackStageView.qml" line="504"/>
<location filename="../qml/Qt6/RibbonBackStageView.qml" line="504"/>
<location filename="../qml/Qt6/RibbonBackStageView.qml" line="498"/>
<source>Restore</source>
<translation></translation>
</message>
<message>
<location filename="../qml/Qt5/RibbonBackStageView.qml" line="504"/>
<location filename="../qml/Qt6/RibbonBackStageView.qml" line="504"/>
<location filename="../qml/Qt6/RibbonBackStageView.qml" line="498"/>
<source>Maximize</source>
<translation></translation>
</message>
@ -114,14 +114,6 @@
</context>
<context>
<name>RibbonMessageBarGroup</name>
<message>
<location filename="../qml/Qt5/RibbonMessageBarGroup.qml" line="102"/>
<location filename="../qml/Qt5/RibbonMessageBarGroup.qml" line="111"/>
<location filename="../qml/Qt6/RibbonMessageBarGroup.qml" line="102"/>
<location filename="../qml/Qt6/RibbonMessageBarGroup.qml" line="111"/>
<source>&apos;s </source>
<translation> </translation>
</message>
<message>
<location filename="../qml/Qt5/RibbonMessageBarGroup.qml" line="180"/>
<location filename="../qml/Qt6/RibbonMessageBarGroup.qml" line="180"/>
@ -202,7 +194,7 @@
</message>
<message>
<location filename="../qml/Qt5/RibbonTabBar.qml" line="302"/>
<location filename="../qml/Qt6/RibbonTabBar.qml" line="302"/>
<location filename="../qml/Qt6/RibbonTabBar.qml" line="301"/>
<source>RibbonTabBar: Error loading component:</source>
<translation>RibbonTabBar</translation>
</message>
@ -353,31 +345,31 @@
<name>RibbonWindow</name>
<message>
<location filename="../qml/Qt5/RibbonWindow.qml" line="148"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="148"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="149"/>
<source>Quit</source>
<translation>退</translation>
</message>
<message>
<location filename="../qml/Qt5/RibbonWindow.qml" line="149"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="149"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="150"/>
<source>Minimize</source>
<translation></translation>
</message>
<message>
<location filename="../qml/Qt5/RibbonWindow.qml" line="150"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="150"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="151"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../qml/Qt5/RibbonWindow.qml" line="151"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="151"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="152"/>
<source>Do you want to close this window?</source>
<translation></translation>
</message>
<message>
<location filename="../qml/Qt5/RibbonWindow.qml" line="152"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="152"/>
<location filename="../qml/Qt6/RibbonWindow.qml" line="153"/>
<source>Please note</source>
<translation></translation>
</message>

View File

@ -9,6 +9,7 @@ class PlatformSupport : public QObject
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
QML_NAMED_ELEMENT(PlatformSupport)
public:
static PlatformSupport* create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return instance();}
static PlatformSupport* instance(){

View File

@ -10,6 +10,7 @@ class RibbonLocalization : public QQuickItem
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
QML_NAMED_ELEMENT(RibbonLocalization)
Q_PROPERTY(QString currentLanguage READ currentLanguage WRITE setCurrentLanguage NOTIFY currentLanguageChanged FINAL)
public:
typedef QPair<QString, QString> LangItem; // example: <"zh_CN", "qrc://i18n/xxx_zh_CN.qm">

View File

@ -9,6 +9,7 @@ class RibbonTheme : public QQuickItem
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
QML_NAMED_ELEMENT(RibbonTheme)
Q_PROPERTY(bool isDarkMode READ isDarkMode NOTIFY isDarkModeChanged FINAL)
Q_PROPERTY_RW(RibbonThemeType::ThemeMode,themeMode)

View File

@ -10,7 +10,7 @@ class RibbonUI : public QQuickItem
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
QML_NAMED_ELEMENT(RibbonUI)
Q_PROPERTY_R(QString, version)
Q_PROPERTY_R(int, qtVersion)
Q_PROPERTY_R(int, isWin11)

View File

@ -74,6 +74,7 @@ Window {
windowAgent.setWindowAttribute("blur-effect", blurBehindWindow ? RibbonTheme.isDarkMode ? "dark" : "light" : "none")
}
RibbonLocalization.bindEngine();
RibbonLocalization.currentLanguage = "en_US"
RibbonUI.setTranslator(RibbonLocalization)
}
Item{