增加多语言

This commit is contained in:
alainchen
2021-02-13 21:44:53 +08:00
parent fdf98f6374
commit 00068832a2
4 changed files with 59 additions and 3 deletions

View File

@ -17,6 +17,8 @@ RC_ICONS = icon.ico
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
TRANSLATIONS += English.ts\
Chinese.ts
SOURCES += \
about_dialog.cpp \

View File

@ -1110,3 +1110,23 @@ void MainWindow::on_actionAdd_to_popular_triggered()
}
}
}
void MainWindow::on_actionChinese_triggered()
{
QTranslator m;
QString currentPath = QCoreApplication::applicationDirPath();
m.load(currentPath+"/lang/Chinese.qm");
qApp->installTranslator(&m);
this->ui->retranslateUi(this);
}
void MainWindow::on_actionEnglish_triggered()
{
QString currentPath = QCoreApplication::applicationDirPath();
QTranslator m;
m.load(currentPath+"/lang/English.qm");
qApp->installTranslator(&m);
this->ui->retranslateUi(this);
}

View File

@ -81,6 +81,10 @@ private slots:
void on_actionAdd_to_popular_triggered();
void on_actionChinese_triggered();
void on_actionEnglish_triggered();
private:
Ui::MainWindow *ui;

View File

@ -137,7 +137,7 @@
</size>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
@ -149,7 +149,7 @@
</rect>
</property>
<attribute name="label">
<string>Page 1</string>
<string>Popular</string>
</attribute>
</widget>
<widget class="QWidget" name="toolbox_system">
@ -162,7 +162,7 @@
</rect>
</property>
<attribute name="label">
<string>System</string>
<string>Examples</string>
</attribute>
<widget class="QListView" name="listView_left">
<property name="geometry">
@ -377,9 +377,29 @@ p, li { white-space: pre-wrap; }
</property>
<addaction name="actionAbout"/>
</widget>
<widget class="QMenu" name="menuTools">
<property name="title">
<string>Tools</string>
</property>
<widget class="QMenu" name="menuPreferences">
<property name="title">
<string>Preferences</string>
</property>
<widget class="QMenu" name="menuLanguage">
<property name="title">
<string>Language</string>
</property>
<addaction name="actionChinese"/>
<addaction name="actionEnglish"/>
</widget>
<addaction name="menuLanguage"/>
</widget>
<addaction name="menuPreferences"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menuCode"/>
<addaction name="menuTools"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
@ -458,6 +478,16 @@ p, li { white-space: pre-wrap; }
<string>Add to popular</string>
</property>
</action>
<action name="actionChinese">
<property name="text">
<string>Chinese</string>
</property>
</action>
<action name="actionEnglish">
<property name="text">
<string>English</string>
</property>
</action>
</widget>
<resources/>
<connections/>