diff --git a/Resource.qrc b/Resource.qrc index 22bce9f..537d56a 100644 --- a/Resource.qrc +++ b/Resource.qrc @@ -11,5 +11,6 @@ <file>icon/dialog-warning.svg</file> <file>icon/icon.svg</file> <file>shell/kernel-installer-remove-template.sh</file> + <file>translation/gxde-kernel-manager_zh_CN.qm</file> </qresource> </RCC> diff --git a/gxde-kernel-manager.pro b/gxde-kernel-manager.pro index 399ab89..7af6b98 100644 --- a/gxde-kernel-manager.pro +++ b/gxde-kernel-manager.pro @@ -51,6 +51,7 @@ target.path=/opt/apps/gxde-kernel-manager/ INSTALLS+= aptsourcegpg aptsource target debiandesktop uosdesktop icon +TRANSLATIONS += translation/gxde-kernel-manager_zh_CN.ts RESOURCES += \ Resource.qrc diff --git a/main.cpp b/main.cpp index 73de6e5..ca07900 100644 --- a/main.cpp +++ b/main.cpp @@ -10,6 +10,13 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); + QTranslator translator; + // 检查系统语言以加载翻译 + if(QProcessEnvironment::systemEnvironment().value("LANG").contains("zh")) { + // 中文,加载中文翻译 + translator.load(":/translation/gxde-kernel-manager_zh_CN.qm"); + } + a.installTranslator(&translator); #ifdef __linux__ // 风险提示 if(!QFile::exists(QDir::homePath() + "/.config/gxde-kernel-manager/read_already")) { diff --git a/translation/gxde-kernel-manager_zh_CN.ts b/translation/gxde-kernel-manager_zh_CN.ts new file mode 100644 index 0000000..ca508f9 --- /dev/null +++ b/translation/gxde-kernel-manager_zh_CN.ts @@ -0,0 +1,186 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="zh_CN"> +<context> + <name>AboutWindow</name> + <message> + <location filename="../aboutwindow.ui" line="14"/> + <source>About</source> + <translation>关于</translation> + </message> + <message> + <location filename="../aboutwindow.ui" line="25"/> + <source><html><head/><body><p><img width=128 src=":/icon/icon.svg"/></p></body></html></source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../aboutwindow.ui" line="55"/> + <source>OK</source> + <translation>确定</translation> + </message> +</context> +<context> + <name>KernelInstaller</name> + <message> + <location filename="../kernelinstaller.ui" line="14"/> + <source>Kernel Installer</source> + <translation>安装内核</translation> + </message> + <message> + <location filename="../kernelinstaller.ui" line="33"/> + <location filename="../kernelinstaller.ui" line="46"/> + <source>TextLabel</source> + <translation>文本标签</translation> + </message> + <message> + <location filename="../kernelinstaller.cpp" line="27"/> + <source>Try to install </source> + <translation>正在尝试安装 </translation> + </message> + <message> + <location filename="../kernelinstaller.cpp" line="29"/> + <source>Try to remove </source> + <translation>尝试移除 </translation> + </message> + <message> + <location filename="../kernelinstaller.cpp" line="131"/> + <source>Done</source> + <translation>完成</translation> + </message> + <message> + <location filename="../kernelinstaller.cpp" line="136"/> + <source>Something error, exit code: </source> + <translation>出现错误,退出代码: </translation> + </message> +</context> +<context> + <name>MainWindow</name> + <message> + <location filename="../mainwindow.ui" line="14"/> + <source>Kerne Manager</source> + <translation>GXDE 内核管理器</translation> + </message> + <message> + <location filename="../mainwindow.ui" line="43"/> + <source>TextLabel</source> + <translation>文本标签</translation> + </message> + <message> + <location filename="../mainwindow.ui" line="63"/> + <source>Refresh</source> + <translation>刷新</translation> + </message> + <message> + <location filename="../mainwindow.ui" line="70"/> + <source>Install</source> + <translation>安装</translation> + </message> + <message> + <location filename="../mainwindow.ui" line="77"/> + <source>Remove</source> + <translation>卸载</translation> + </message> + <message> + <location filename="../mainwindow.ui" line="96"/> + <source>Program</source> + <translation>程序</translation> + </message> + <message> + <location filename="../mainwindow.ui" line="102"/> + <source>Help</source> + <translation>帮助</translation> + </message> + <message> + <location filename="../mainwindow.ui" line="115"/> + <source>Exit</source> + <translation>退出</translation> + </message> + <message> + <location filename="../mainwindow.ui" line="120"/> + <source>About</source> + <translation>关于</translation> + </message> + <message> + <location filename="../mainwindow.ui" line="125"/> + <source>Gitee</source> + <translation>Gitee</translation> + </message> + <message> + <location filename="../mainwindow.ui" line="130"/> + <source>Github</source> + <translation>Github</translation> + </message> + <message> + <location filename="../mainwindow.cpp" line="21"/> + <source>Kernel: </source> + <translation>内核: </translation> + </message> + <message> + <location filename="../mainwindow.cpp" line="21"/> + <source>Arch: </source> + <translation>架构: </translation> + </message> + <message> + <location filename="../mainwindow.cpp" line="34"/> + <source>ID</source> + <translation>ID</translation> + </message> + <message> + <location filename="../mainwindow.cpp" line="34"/> + <source>Kernel Name</source> + <translation>内核名称</translation> + </message> + <message> + <location filename="../mainwindow.cpp" line="34"/> + <source>Author</source> + <translation>维护者</translation> + </message> + <message> + <location filename="../mainwindow.cpp" line="34"/> + <source>Arch</source> + <translation>架构</translation> + </message> + <message> + <location filename="../mainwindow.cpp" line="34"/> + <source>Installed</source> + <translation>是否安装</translation> + </message> + <message> + <location filename="../mainwindow.cpp" line="63"/> + <location filename="../mainwindow.cpp" line="106"/> + <source>Error</source> + <translation>错误</translation> + </message> + <message> + <location filename="../mainwindow.cpp" line="63"/> + <location filename="../mainwindow.cpp" line="106"/> + <source>Nothing to choose</source> + <translation>没有选择任何选项</translation> + </message> +</context> +<context> + <name>QObject</name> + <message> + <location filename="../main.cpp" line="16"/> + <source>Waring</source> + <translation>警告</translation> + </message> + <message> + <location filename="../main.cpp" line="16"/> + <source>It is danger because it may make your system unboot. +Press 'OK' to countinue</source> + <translation>免责声明: +操作内核有可能导致系统无法正常启动,按“OK”键继续</translation> + </message> + <message> + <location filename="../main.cpp" line="23"/> + <source>Error</source> + <translation>错误</translation> + </message> + <message> + <location filename="../main.cpp" line="23"/> + <source>It unsupport Windows</source> + <translation>该程序不支持 Windows</translation> + </message> +</context> +</TS>