diff --git a/kylin-nm.pro b/kylin-nm.pro index 7b52af76..1f13a7c2 100644 --- a/kylin-nm.pro +++ b/kylin-nm.pro @@ -12,3 +12,12 @@ TRANSLATIONS += \ translations/kylin-nm_tr.ts \ translations/kylin-nm_bo.ts \ translations/kylin-nm_bo_CN.ts + +CONFIG(release, debug|release) { + !system($$PWD/translate_generation.sh): error("Failed to generate translation") +} + +qm_files.path = $${PREFIX}/share/kylin-nm/kylin-nm/ +qm_files.files = translations/*.qm + +INSTALLS += qm_files \ diff --git a/nmqrc.qrc b/nmqrc.qrc index c379b198..aea1ec48 100644 --- a/nmqrc.qrc +++ b/nmqrc.qrc @@ -17,9 +17,6 @@ res/h/right-pwd.png res/h/show-pwd.png res/h/no-pwd-wifi.png - translations/kylin-nm_bo.qm - translations/kylin-nm_tr.qm - translations/kylin-nm_zh_CN.qm res/x/fly-mode-off.svg res/x/fly-mode-on.svg res/x/hot-spot-off.svg @@ -128,6 +125,5 @@ res/s/conning-b/10.png res/s/conning-b/11.png res/s/conning-b/12.png - translations/kylin-nm_bo_CN.qm diff --git a/src/main.cpp b/src/main.cpp index 2454937e..e8660476 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -127,7 +127,7 @@ int main(int argc, char *argv[]) QString locale = QLocale::system().name(); QTranslator trans_global; qDebug() << "QLocale " << QLocale(); - if (trans_global.load(QLocale(), "kylin-nm", "_", ":/translations/")) + if (trans_global.load(QLocale(), "kylin-nm", "_", "/usr/share/kylin-nm/kylin-nm/")) { a.installTranslator(&trans_global); qDebug()<<"Translations load success"; @@ -144,6 +144,15 @@ int main(int argc, char *argv[]) qWarning() << "QtBase Translations load fail"; } + QTranslator sdkTranslator; + if (sdkTranslator.load(QLocale(), "gui", "_", ":/translations/")) + { + a.installTranslator(&sdkTranslator); + qDebug()<<"SDK Translations load success"; + } else { + qWarning() << "SDK Translations load fail"; + } + while (!p_networkResource->NetworkManagerIsInited()) { ::usleep(1000); } diff --git a/translate_generation.sh b/translate_generation.sh new file mode 100755 index 00000000..72f748b9 --- /dev/null +++ b/translate_generation.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +ts_list=(`ls translations/*.ts`) +source /etc/os-release +version=(`echo $ID`) + +for ts in "${ts_list[@]}" +do + printf "\nprocess ${ts}\n" + if [ "$version" == "fedora" ] || [ "$version" == "opensuse-leap" ] || [ "$version" == "opensuse-tumbleweed" ];then + lrelease-qt5 "${ts}" + else + lrelease "${ts}" + fi +done diff --git a/translations/kylin-nm_bo.qm b/translations/kylin-nm_bo.qm deleted file mode 100644 index be651eed..00000000 --- a/translations/kylin-nm_bo.qm +++ /dev/null @@ -1 +0,0 @@ -<¸dÊÍ!¿`¡½Ý \ No newline at end of file diff --git a/translations/kylin-nm_bo_CN.qm b/translations/kylin-nm_bo_CN.qm deleted file mode 100644 index fa461605..00000000 Binary files a/translations/kylin-nm_bo_CN.qm and /dev/null differ diff --git a/translations/kylin-nm_tr.qm b/translations/kylin-nm_tr.qm deleted file mode 100644 index 67ee71e8..00000000 Binary files a/translations/kylin-nm_tr.qm and /dev/null differ diff --git a/translations/kylin-nm_zh_CN.qm b/translations/kylin-nm_zh_CN.qm deleted file mode 100644 index 2241f2ab..00000000 Binary files a/translations/kylin-nm_zh_CN.qm and /dev/null differ