diff --git a/.gitignore b/.gitignore
index f594cd3..05d6dde 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
# Add by me:
bin/*
+*.qm
# following are get from gitHub:
diff --git a/AboutDlg.ui b/AboutDlg.ui
index 35ae8f0..4154023 100644
--- a/AboutDlg.ui
+++ b/AboutDlg.ui
@@ -17,7 +17,7 @@
-
- Email: LiaoChengO@qq.com
+ Email: LiaoChengO@qq.com
https://github.com/CharlesLiaoO/EncodingConverter
Build with Qt/C++
@@ -31,7 +31,7 @@ Build with Qt/C++
-
- About Qt
+ About Qt
diff --git a/EncodingConverter.pro b/EncodingConverter.pro
index f1d7747..e83d209 100644
--- a/EncodingConverter.pro
+++ b/EncodingConverter.pro
@@ -36,3 +36,5 @@ FORMS += \
RESOURCES += \
Res/res.qrc
+
+TRANSLATIONS += Res/translations/zh_CN.ts
diff --git a/MainWindow.cpp b/MainWindow.cpp
index 7cb4c81..c6e0bd8 100644
--- a/MainWindow.cpp
+++ b/MainWindow.cpp
@@ -235,11 +235,15 @@ void MainWindow::on_pushButton_Start_clicked()
QFile fileSrc(fiFileSrc.absoluteFilePath());
QFile fileDest(fileSrc.fileName() + sTmpSuffixName);
if (!fileSrc.open(QFile::ReadOnly/* | QFile::Text*/)) { // Text mode has no effect in read mode
- QMessageBox::critical(this, "", tr("Error when open input file"));
+ QString sOpenErr = tr("Error when open input file\n%1").arg(fileSrc.fileName());
+ ui->plainTextEdit_MsgOutput->appendPlainText(sOpenErr);
+ QMessageBox::critical(this, "", sOpenErr);
return;
}
if (!fileDest.open(QFile::WriteOnly)) { // Not use Text mode, because we need to specify newline char
- QMessageBox::critical(this, "", tr("Error when open tmp output file"));
+ QString sOpenErr = tr("Error when open temporary output file\n%1").arg(fileDest.fileName());
+ ui->plainTextEdit_MsgOutput->appendPlainText(sOpenErr);
+ QMessageBox::critical(this, "", sOpenErr);
return;
}
diff --git a/MainWindow.ui b/MainWindow.ui
index b84b81c..2c363b8 100644
--- a/MainWindow.ui
+++ b/MainWindow.ui
@@ -190,7 +190,7 @@
- *.cpp;*.h;*.c;*.hpp
+ *.cpp;*.h;*.c;*.hpp
diff --git a/Res/res.qrc b/Res/res.qrc
index 5e3886d..ed234a1 100644
--- a/Res/res.qrc
+++ b/Res/res.qrc
@@ -1,10 +1,8 @@
- translations/qtMod_zh_CN.qm
- images/pause_Tbn.png
- images/start_Tbn.png
- images/stop_Tbn.png
- images/setting.png
images/locale.png
+ images/setting.png
+ translations/qtMod_zh_CN.qm
+ translations/zh_CN.qm
diff --git a/Res/translations/zh_CN.ts b/Res/translations/zh_CN.ts
new file mode 100644
index 0000000..063f5a9
--- /dev/null
+++ b/Res/translations/zh_CN.ts
@@ -0,0 +1,215 @@
+
+
+
+
+ AboutDlg
+
+
+
+ 关于软件
+
+
+
+ MainWindow
+
+
+
+ 文本编码转换器
+
+
+
+
+ 编码
+
+
+
+
+
+
+ 输入:
+
+
+
+
+ 自动检测(支持UTF和系统编码)
+
+
+
+
+
+
+ 输出:
+
+
+
+
+ 输入编码与输出相同时跳过
+
+
+
+
+ 文件夹或文件
+
+
+
+
+ 浏览
+
+
+
+
+ 如果备份,则在同级目录中复制文件X为X.ecbak
+
+
+
+
+ 递归包含子文件夹和文件
+
+
+
+
+ 覆盖输入
+
+
+
+
+ 备份
+
+
+
+
+ 拓展名
+
+
+
+
+ 换行符
+
+
+
+
+ 任意
+
+
+
+
+ 开始
+
+
+
+
+ 停止
+
+
+
+
+ 文件:
+
+
+
+
+ 消息输出
+
+
+
+
+ 系统(Windows中为ANSI)
+
+
+
+
+ 选择一个目录
+
+
+
+
+ ---- 开始于 %1 ----
+
+
+
+
+ 不存在或非法的路径
+
+
+
+
+ 正在递归查找文件...
+
+
+
+
+ 开始转换...
+
+
+
+
+ 错误:打开输入文件:\n%1
+
+
+
+
+ 错误:打开临时输出文件:\n%1
+
+
+
+
+ %1
+ 的输入编码与输出相同,跳过
+
+
+
+
+ ---- 完成于 %1 ----
+
+
+
+
+ %1
+ 的大小 >= %2GB,跳过
+
+
+
+
+ 大文件确认
+
+
+
+
+ %1
+'的大小 > %2MB,仍要转换吗?
+
+
+
+
+ %0 (%1 行, %2%)
+
+
+
+ SettingDlg
+
+
+
+ 设置
+
+
+
+
+ 语言:
+
+
+
+
+ 系统
+
+
+
+
+ 重启后生效
+
+
+
diff --git a/SettingDlg.cpp b/SettingDlg.cpp
index 1e3bbcd..94c1800 100644
--- a/SettingDlg.cpp
+++ b/SettingDlg.cpp
@@ -20,7 +20,7 @@ SettingDlg::SettingDlg(QWidget *parent) :
// langList<< "English";
// ui->comboBox_Lang->addItems(langList);
- ui->comboBox_Lang->addItem(tr("System(系统)"), "System");
+ ui->comboBox_Lang->addItem(tr("System"), "System");
ui->comboBox_Lang->addItem("Chinese(中文)", "Chinese");
ui->comboBox_Lang->addItem("English", "English");
diff --git a/main.cpp b/main.cpp
index 8d4f9af..7ff1d52 100644
--- a/main.cpp
+++ b/main.cpp
@@ -5,31 +5,33 @@
#include
#include
-void LoadQtTranslation(QTranslator &tr_qt, QLocale::Language lang);
+QTranslator trQt, trApp;
+void LoadTranslator(QLocale::Language lang);
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- QTranslator tr_qt;
IniSetting cfg("config.ini");
QString sLanguage = cfg.value("language", "System").toString();
if (sLanguage == "System")
- LoadQtTranslation(tr_qt, QLocale().language());
+ LoadTranslator(QLocale().language());
else if (sLanguage == "Chinese")
- LoadQtTranslation(tr_qt, QLocale::Chinese);
- a.installTranslator(&tr_qt);
+ LoadTranslator(QLocale::Chinese);
+ a.installTranslator(&trQt);
+ a.installTranslator(&trApp);
MainWindow w;
w.show();
return a.exec();
}
-void LoadQtTranslation(QTranslator &tr_qt, QLocale::Language lang)
+void LoadTranslator(QLocale::Language lang)
{
switch (lang) {
case QLocale::Chinese:
- tr_qt.load(":/translations/qtMod_zh_CN.qm"); // modified from qt office release
+ trQt.load(":/translations/qtMod_zh_CN.qm"); // modified from qt office release
+ trApp.load(":/translations/zh_CN.qm");
break;
default:
break;