diff --git a/.gitignore b/.gitignore index b325fd1..24d835b 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,8 @@ Thumbs.db /.qmake.cache /.qmake.stash +*.qrc.depends + # qtcreator generated files *.pro.user* CMakeLists.txt.user* diff --git a/.lupdate/translations/en_US.ts.stamp b/.lupdate/translations/en_US.ts.stamp deleted file mode 100644 index e69de29..0000000 diff --git a/.lupdate/translations/ru_RU.ts.stamp b/.lupdate/translations/ru_RU.ts.stamp deleted file mode 100644 index e69de29..0000000 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4df4ede..77a67c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,7 @@ else() # Generate translation files for Qt 5 # QT5_ADD_TRANSLATION() qt5_create_translation(QM_FILES "${TRANSLATION_SOURCES}" translations/en_US.ts translations/ru_RU.ts) - # qt_add_translation(checks-parser TS_FILES translations/en_US.ts translations/ru_RU.ts) + qt5_add_resources(TRANSLATIONQRC translations.qrc) add_executable(checks-parser ${PROJECT_SOURCES} goods/goods.h goods/goods.cpp @@ -75,12 +75,11 @@ else() image_redactor/imageredactor.h image_redactor/imageredactor.cpp solvecaptchadialog.h solvecaptchadialog.cpp solvecaptchadialog.ui exceptions/ofdrequestexception.h exceptions/ofdrequestexception.cpp - ${QM_FILES} - ${TS_FILES} + # ${QM_FILES} + # ${TS_FILES} + translations.qrc + ${TRANSLATIONQRC} ) - - - # configure_file(translations.qrc ${CMAKE_BINARY_DIR} COPYONLY) # QT5_ADD_TRANSLATION(TRANSLATIONS ${CMAKE_SOURCE_DIR} translations/en_US.ts) endif() diff --git a/deploy/appimage/deploy.sh b/deploy/appimage/deploy.sh index 360225f..6a9642d 100755 --- a/deploy/appimage/deploy.sh +++ b/deploy/appimage/deploy.sh @@ -7,8 +7,6 @@ mkdir -p AppDir/usr/lib mkdir -p AppDir/usr/share/tesseract-ocr/4.00/tessdata cp -r /usr/share/tesseract-ocr/4.00/tessdata/* AppDir/usr/share/tesseract-ocr/4.00/tessdata cp ../../checks-parser AppDir/usr/bin -cp ../../en_US.qm AppDir/ -cp ../../ru_RU.qm AppDir/ echo \ "[Desktop Entry] diff --git a/main.cpp b/main.cpp index abfbb71..edd4e1f 100644 --- a/main.cpp +++ b/main.cpp @@ -12,6 +12,8 @@ # include using namespace std::filesystem; #endif +#include +#include #include int main(int argc, char *argv[]) { @@ -46,13 +48,17 @@ int main(int argc, char *argv[]) { QString lang = "en_US"; if (s.get_all_settings().contains("language")) { + std::cout << "settings" << std::endl; lang = QString::fromStdString(s.get_all_settings()["language"]); - } else if (translator.load(QLocale::system().name())) { + } else if (translator.load(":/translation/"+QLocale::system().name()+".qm")) { + std::cout << "system" << std::endl; lang = QLocale::system().name(); } else { + std::cout << "default" << std::endl; lang = QString::fromStdString("en_US"); } - translator.load(lang); + std::cout << lang.toStdString() << std::endl; + translator.load(":/translation/" + lang + ".qm"); a.installTranslator(&translator); MainWindow w; diff --git a/translations.qrc b/translations.qrc new file mode 100644 index 0000000..ed12877 --- /dev/null +++ b/translations.qrc @@ -0,0 +1,7 @@ + + + en_US.qm + ru_RU.qm + + + diff --git a/translations/ru_RU.ts b/translations/ru_RU.ts index cccbea1..6b93b4b 100644 --- a/translations/ru_RU.ts +++ b/translations/ru_RU.ts @@ -307,12 +307,12 @@ SettingsDialog - + You need to restart program to apply language changes Требуется перезагрузить программу, чтобы применить изменения языка - + Restart required Требуется перезагрузка