diff --git a/main.cpp b/main.cpp index 3549a9b..69ab8b6 100644 --- a/main.cpp +++ b/main.cpp @@ -33,9 +33,32 @@ static QWidget *loadUI(QWidget *parent, std::string filename) { } int main(int argc, char *argv[]) { - QUiLoader loader; + QApplication app(argc, argv); + std::string settings_file_path = + get_path_relative_to_home(".local/share/checks_parser/settings.json"); + + Settings s(settings_file_path); + + QTranslator translator; + QString lang = "en_US"; + + if (s.get_all_settings().contains("language")) { + lang = QString::fromStdString(s.get_all_settings()["language"]); + } else if (translator.load(":/translation/"+QLocale::system().name()+".qm")) { + lang = QLocale::system().name(); + } else { + lang = QString::fromStdString("en_US"); + } + + std::cout << "Using locale: " << lang.toStdString() << std::endl; + + translator.load(":/translation/" + lang + ".qm"); + app.installTranslator(&translator); + + QUiLoader loader; + QWidget *window = new QWidget(); QStackedLayout *sceneLayout = new QStackedLayout; @@ -69,7 +92,7 @@ int main(int argc, char *argv[]) { OCRScene *ocrscene = new OCRScene(); OFDScene *ofdscene = new OFDScene(); - ofdscene->startHttpServer(); + // ofdscene->startHttpServer(); // get_local_ip_address(); @@ -90,6 +113,8 @@ int main(int argc, char *argv[]) { }); } + + window->setLayout(sceneLayout); window->show(); @@ -139,10 +164,10 @@ int main(int argc, char *argv[]) { std::string program_data_path = get_path_relative_to_home(".local/share/checks_parser"); create_directories(program_data_path); - std::string settings_file_path = - get_path_relative_to_home(".local/share/checks_parser/settings.json"); + // std::string settings_file_path = + // get_path_relative_to_home(".local/share/checks_parser/settings.json"); - Settings s(settings_file_path); + // Settings s(settings_file_path); Net n; Parser p; @@ -161,22 +186,22 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - QTranslator translator; - QString lang = "en_US"; + // QTranslator translator; + // QString lang = "en_US"; - if (s.get_all_settings().contains("language")) { - lang = QString::fromStdString(s.get_all_settings()["language"]); - } else if (translator.load(":/translation/"+QLocale::system().name()+".qm")) { - lang = QLocale::system().name(); - } else { - lang = QString::fromStdString("en_US"); - } + // if (s.get_all_settings().contains("language")) { + // lang = QString::fromStdString(s.get_all_settings()["language"]); + // } else if (translator.load(":/translation/"+QLocale::system().name()+".qm")) { + // lang = QLocale::system().name(); + // } else { + // lang = QString::fromStdString("en_US"); + // } - std::cout << "Using locale: " << lang.toStdString() << std::endl; + // std::cout << "Using locale: " << lang.toStdString() << std::endl; - translator.load(":/translation/" + lang + ".qm"); + // translator.load(":/translation/" + lang + ".qm"); - a.installTranslator(&translator); + // a.installTranslator(&translator); MainWindow w; w.update(); w.show(); diff --git a/translations/en_US.ts b/translations/en_US.ts index bd82b03..49b8dfd 100644 --- a/translations/en_US.ts +++ b/translations/en_US.ts @@ -29,7 +29,7 @@ <message> <location filename="../scenes/emailtextscene.ui" line="14"/> <source>Form</source> - <translation type="unfinished"></translation> + <translation>Form</translation> </message> <message> <source>Store type</source> @@ -38,32 +38,32 @@ <message> <location filename="../scenes/emailtextscene.ui" line="26"/> <source>Check content</source> - <translation type="unfinished">Check content</translation> + <translation>Check content</translation> </message> <message> <location filename="../scenes/emailtextscene.ui" line="33"/> <source>Parse</source> - <translation type="unfinished">Parse</translation> + <translation>Parse</translation> </message> <message> <location filename="../scenes/emailtextscene.ui" line="46"/> <source>Store:</source> - <translation type="unfinished"></translation> + <translation>Store:</translation> </message> <message> <location filename="../scenes/emailtextscene.ui" line="62"/> <source>Back</source> - <translation type="unfinished"></translation> + <translation>Back</translation> </message> <message> <location filename="../emailtextscene.cpp" line="31"/> <source>An error has occured. Check was matched incorrectly. Vector sizes are different. Please, contact the developer.</source> - <translation type="unfinished">An error has occured. Check was matched incorrectly. Vector sizes are different. Please, contact the developer.</translation> + <translation>An error has occured. Check was matched incorrectly. Vector sizes are different. Please, contact the developer.</translation> </message> <message> <location filename="../emailtextscene.cpp" line="33"/> <source>Error in parsing</source> - <translation type="unfinished">Error in parsing</translation> + <translation>Error in parsing</translation> </message> </context> <context> @@ -208,17 +208,17 @@ <message> <location filename="../scenes/mainwindow.ui" line="26"/> <source>Form</source> - <translation type="unfinished"></translation> + <translation>Form</translation> </message> <message> <location filename="../scenes/mainwindow.ui" line="37"/> <source>Optical Character Recognition</source> - <translation type="unfinished"></translation> + <translation>Optical Character Recognition</translation> </message> <message> <location filename="../scenes/mainwindow.ui" line="63"/> <source>Text from E-Mail</source> - <translation type="unfinished"></translation> + <translation>Text from E-Mail</translation> </message> </context> <context> @@ -226,62 +226,62 @@ <message> <location filename="../scenes/ocrscene.ui" line="20"/> <source>Form</source> - <translation type="unfinished"></translation> + <translation>Form</translation> </message> <message> <location filename="../scenes/ocrscene.ui" line="64"/> <source>Choose</source> - <translation type="unfinished">Choose</translation> + <translation>Choose</translation> </message> <message> <location filename="../scenes/ocrscene.ui" line="103"/> <source>Path to image:</source> - <translation type="unfinished"></translation> + <translation>Path to image:</translation> </message> <message> <location filename="../scenes/ocrscene.ui" line="119"/> <source>Store:</source> - <translation type="unfinished"></translation> + <translation>Store:</translation> </message> <message> <location filename="../scenes/ocrscene.ui" line="90"/> <source>Recognized text will be shown below as soon as image will be processed. Please, edit it</source> - <translation type="unfinished"></translation> + <translation>Recognized text will be shown below as soon as image will be processed. Please, edit it</translation> </message> <message> <location filename="../scenes/ocrscene.ui" line="77"/> <source>Back</source> - <translation type="unfinished"></translation> + <translation>Back</translation> </message> <message> <location filename="../scenes/ocrscene.ui" line="45"/> <source>Parse</source> - <translation type="unfinished">Parse</translation> + <translation>Parse</translation> </message> <message> <location filename="../ocrscene.cpp" line="36"/> <source>An error has occured. Check was matched incorrectly. Vector sizes are different. Please, contact the developer.</source> - <translation type="unfinished">An error has occured. Check was matched incorrectly. Vector sizes are different. Please, contact the developer.</translation> + <translation>An error has occured. Check was matched incorrectly. Vector sizes are different. Please, contact the developer.</translation> </message> <message> <location filename="../ocrscene.cpp" line="38"/> <source>Error in parsing</source> - <translation type="unfinished">Error in parsing</translation> + <translation>Error in parsing</translation> </message> <message> <location filename="../ocrscene.cpp" line="56"/> <source>Please, select a picture to scan</source> - <translation type="unfinished">Please, select a picture to scan</translation> + <translation>Please, select a picture to scan</translation> </message> <message> <location filename="../ocrscene.cpp" line="58"/> <source>Picture was not selected</source> - <translation type="unfinished">Picture was not selected</translation> + <translation>Picture was not selected</translation> </message> <message> <location filename="../ocrscene.cpp" line="64"/> <source>Path to image: </source> - <translation type="unfinished">Path to image: </translation> + <translation>Path to image: </translation> </message> </context> <context> @@ -289,127 +289,127 @@ <message> <location filename="../scenes/ofdscene.ui" line="14"/> <source>Form</source> - <translation type="unfinished"></translation> + <translation>Form</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="23"/> <source>Total</source> - <translation type="unfinished">Total</translation> + <translation>Total</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="36"/> <source>Back</source> - <translation type="unfinished"></translation> + <translation>Back</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="49"/> <source>or</source> - <translation type="unfinished"></translation> + <translation>or</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="69"/> <source>FD (Fiscal Document)</source> - <translation type="unfinished">FD (Fiscal Document)</translation> + <translation>FD (Fiscal Document)</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="76"/> <source>Date and time of purchase</source> - <translation type="unfinished"></translation> + <translation>Date and time of purchase</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="84"/> <source>Funds income</source> - <translation type="unfinished">Funds income</translation> + <translation>Funds income</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="89"/> <source>Funds return</source> - <translation type="unfinished">Funds return</translation> + <translation>Funds return</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="94"/> <source>Funds spend</source> - <translation type="unfinished">Funds spend</translation> + <translation>Funds spend</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="99"/> <source>Spends return</source> - <translation type="unfinished">Spends return</translation> + <translation>Spends return</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="136"/> <source>Use your phone as a QR code scanner</source> - <translation type="unfinished"></translation> + <translation>Use your phone as a QR code scanner</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="149"/> <source>FN (Fiscal Number)</source> - <translation type="unfinished">FN (Fiscal Number)</translation> + <translation>FN (Fiscal Number)</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="156"/> <source>FI (Fiscal Identifier)</source> - <translation type="unfinished">FI (Fiscal Identifier)</translation> + <translation>FI (Fiscal Identifier)</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="166"/> <source>Choose image on your PC</source> - <translation type="unfinished"></translation> + <translation>Choose image on your PC</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="173"/> <source>Operation type</source> - <translation type="unfinished"></translation> + <translation>Operation type</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="186"/> <source>Parse</source> - <translation type="unfinished">Parse</translation> + <translation>Parse</translation> </message> <message> - <location filename="../ofdscene.cpp" line="48"/> + <location filename="../ofdscene.cpp" line="49"/> <source>Please, select a picture where QR code that contains info about check is present</source> - <translation type="unfinished">Please, select a picture where QR code that contains info about check is present</translation> + <translation>Please, select a picture where QR code that contains info about check is present</translation> </message> <message> - <location filename="../ofdscene.cpp" line="50"/> + <location filename="../ofdscene.cpp" line="51"/> <source>Picture was not selected</source> - <translation type="unfinished">Picture was not selected</translation> + <translation>Picture was not selected</translation> </message> <message> - <location filename="../ofdscene.cpp" line="56"/> + <location filename="../ofdscene.cpp" line="57"/> <source>Selected image: </source> - <translation type="unfinished"></translation> + <translation>Selected image: </translation> </message> <message> - <location filename="../ofdscene.cpp" line="115"/> + <location filename="../ofdscene.cpp" line="116"/> <source>Captcha was not solved correctly!</source> - <translation type="unfinished">Captcha was not solved correctly!</translation> + <translation>Captcha was not solved correctly!</translation> </message> <message> - <location filename="../ofdscene.cpp" line="117"/> + <location filename="../ofdscene.cpp" line="118"/> <source>Captcha is incorrect</source> - <translation type="unfinished">Captcha is incorrect</translation> + <translation>Captcha is incorrect</translation> </message> <message> - <location filename="../ofdscene.cpp" line="122"/> + <location filename="../ofdscene.cpp" line="123"/> <source>Internal server error. Please, try again later.</source> - <translation type="unfinished">Internal server error. Please, try again later.</translation> + <translation>Internal server error. Please, try again later.</translation> </message> <message> - <location filename="../ofdscene.cpp" line="124"/> + <location filename="../ofdscene.cpp" line="125"/> <source>Internal server error</source> - <translation type="unfinished">Internal server error</translation> + <translation>Internal server error</translation> </message> <message> - <location filename="../ofdscene.cpp" line="129"/> + <location filename="../ofdscene.cpp" line="130"/> <source>Check not found. Please, ensure correctness of entered data.</source> - <translation type="unfinished">Check not found. Please, ensure correctness of entered data.</translation> + <translation>Check not found. Please, ensure correctness of entered data.</translation> </message> <message> - <location filename="../ofdscene.cpp" line="131"/> + <location filename="../ofdscene.cpp" line="132"/> <source>Check was not found</source> - <translation type="unfinished"></translation> + <translation>Check was not found</translation> </message> </context> <context> diff --git a/translations/ru_RU.ts b/translations/ru_RU.ts index e12d8d7..de475ae 100644 --- a/translations/ru_RU.ts +++ b/translations/ru_RU.ts @@ -29,7 +29,7 @@ <message> <location filename="../scenes/emailtextscene.ui" line="14"/> <source>Form</source> - <translation type="unfinished"></translation> + <translation>Форма</translation> </message> <message> <source>Store type</source> @@ -38,32 +38,32 @@ <message> <location filename="../scenes/emailtextscene.ui" line="26"/> <source>Check content</source> - <translation type="unfinished">Контент чека</translation> + <translation>Контент чека</translation> </message> <message> <location filename="../scenes/emailtextscene.ui" line="33"/> <source>Parse</source> - <translation type="unfinished">Парсить</translation> + <translation>Парсить</translation> </message> <message> <location filename="../scenes/emailtextscene.ui" line="46"/> <source>Store:</source> - <translation type="unfinished"></translation> + <translation>Магазин:</translation> </message> <message> <location filename="../scenes/emailtextscene.ui" line="62"/> <source>Back</source> - <translation type="unfinished"></translation> + <translation>Назад</translation> </message> <message> <location filename="../emailtextscene.cpp" line="31"/> <source>An error has occured. Check was matched incorrectly. Vector sizes are different. Please, contact the developer.</source> - <translation type="unfinished">Произошла ошибка. Чек был прочитан неверно. Размеры векторов различаются. Пожалуйста, сообщите об этом разработчику.</translation> + <translation>Произошла ошибка. Чек был прочитан неверно. Размеры векторов различаются. Пожалуйста, сообщите об этом разработчику.</translation> </message> <message> <location filename="../emailtextscene.cpp" line="33"/> <source>Error in parsing</source> - <translation type="unfinished">Ошибка в парсинге</translation> + <translation>Ошибка в парсинге</translation> </message> </context> <context> @@ -208,17 +208,17 @@ <message> <location filename="../scenes/mainwindow.ui" line="26"/> <source>Form</source> - <translation type="unfinished"></translation> + <translation>Форма</translation> </message> <message> <location filename="../scenes/mainwindow.ui" line="37"/> <source>Optical Character Recognition</source> - <translation type="unfinished"></translation> + <translation>Оптическое распознавание символов</translation> </message> <message> <location filename="../scenes/mainwindow.ui" line="63"/> <source>Text from E-Mail</source> - <translation type="unfinished"></translation> + <translation>Текст из электронного письма</translation> </message> </context> <context> @@ -226,62 +226,62 @@ <message> <location filename="../scenes/ocrscene.ui" line="20"/> <source>Form</source> - <translation type="unfinished"></translation> + <translation>Форма</translation> </message> <message> <location filename="../scenes/ocrscene.ui" line="64"/> <source>Choose</source> - <translation type="unfinished">Выбрать</translation> + <translation>Выбрать</translation> </message> <message> <location filename="../scenes/ocrscene.ui" line="103"/> <source>Path to image:</source> - <translation type="unfinished"></translation> + <translation>Путь к изображению:</translation> </message> <message> <location filename="../scenes/ocrscene.ui" line="119"/> <source>Store:</source> - <translation type="unfinished"></translation> + <translation>Магазин:</translation> </message> <message> <location filename="../scenes/ocrscene.ui" line="90"/> <source>Recognized text will be shown below as soon as image will be processed. Please, edit it</source> - <translation type="unfinished"></translation> + <translation>Распознанный текст будет показан ниже как только изображение обработается. Пожалуйста, отредактируйте</translation> </message> <message> <location filename="../scenes/ocrscene.ui" line="77"/> <source>Back</source> - <translation type="unfinished"></translation> + <translation>Назад</translation> </message> <message> <location filename="../scenes/ocrscene.ui" line="45"/> <source>Parse</source> - <translation type="unfinished">Парсить</translation> + <translation>Парсить</translation> </message> <message> <location filename="../ocrscene.cpp" line="36"/> <source>An error has occured. Check was matched incorrectly. Vector sizes are different. Please, contact the developer.</source> - <translation type="unfinished">Произошла ошибка. Чек был прочитан неверно. Размеры векторов различаются. Пожалуйста, сообщите об этом разработчику.</translation> + <translation>Произошла ошибка. Чек был прочитан неверно. Размеры векторов различаются. Пожалуйста, сообщите об этом разработчику.</translation> </message> <message> <location filename="../ocrscene.cpp" line="38"/> <source>Error in parsing</source> - <translation type="unfinished">Ошибка в парсинге</translation> + <translation>Ошибка в парсинге</translation> </message> <message> <location filename="../ocrscene.cpp" line="56"/> <source>Please, select a picture to scan</source> - <translation type="unfinished">Пожалуйста, выберете изображение для сканирования</translation> + <translation>Пожалуйста, выберете изображение для сканирования</translation> </message> <message> <location filename="../ocrscene.cpp" line="58"/> <source>Picture was not selected</source> - <translation type="unfinished">Изображение не было выбрано</translation> + <translation>Изображение не было выбрано</translation> </message> <message> <location filename="../ocrscene.cpp" line="64"/> <source>Path to image: </source> - <translation type="unfinished">Путь к изображению: </translation> + <translation>Путь к изображению: </translation> </message> </context> <context> @@ -289,127 +289,127 @@ <message> <location filename="../scenes/ofdscene.ui" line="14"/> <source>Form</source> - <translation type="unfinished"></translation> + <translation>Форма</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="23"/> <source>Total</source> - <translation type="unfinished">Итого</translation> + <translation>Итого</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="36"/> <source>Back</source> - <translation type="unfinished"></translation> + <translation>Назад</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="49"/> <source>or</source> - <translation type="unfinished"></translation> + <translation>или</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="69"/> <source>FD (Fiscal Document)</source> - <translation type="unfinished">ФД</translation> + <translation>ФД</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="76"/> <source>Date and time of purchase</source> - <translation type="unfinished"></translation> + <translation>Дата и время покупки</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="84"/> <source>Funds income</source> - <translation type="unfinished">Приход средств</translation> + <translation>Приход средств</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="89"/> <source>Funds return</source> - <translation type="unfinished">Возврат средств</translation> + <translation>Возврат средств</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="94"/> <source>Funds spend</source> - <translation type="unfinished">Расход средств</translation> + <translation>Расход средств</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="99"/> <source>Spends return</source> - <translation type="unfinished">Возврат расхода</translation> + <translation>Возврат расхода</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="136"/> <source>Use your phone as a QR code scanner</source> - <translation type="unfinished"></translation> + <translation>Использовать телефон как сканнер QR</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="149"/> <source>FN (Fiscal Number)</source> - <translation type="unfinished">ФН</translation> + <translation>ФН</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="156"/> <source>FI (Fiscal Identifier)</source> - <translation type="unfinished">ФП</translation> + <translation>ФП</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="166"/> <source>Choose image on your PC</source> - <translation type="unfinished"></translation> + <translation>Выбрать изображение на компьютере</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="173"/> <source>Operation type</source> - <translation type="unfinished"></translation> + <translation>Тип операции</translation> </message> <message> <location filename="../scenes/ofdscene.ui" line="186"/> <source>Parse</source> - <translation type="unfinished">Парсить</translation> + <translation>Парсить</translation> </message> <message> - <location filename="../ofdscene.cpp" line="48"/> + <location filename="../ofdscene.cpp" line="49"/> <source>Please, select a picture where QR code that contains info about check is present</source> - <translation type="unfinished">Пожалуйста, выберете изображение, содержащее QR код с информацией о чеке</translation> + <translation>Пожалуйста, выберете изображение, содержащее QR код с информацией о чеке</translation> </message> <message> - <location filename="../ofdscene.cpp" line="50"/> + <location filename="../ofdscene.cpp" line="51"/> <source>Picture was not selected</source> - <translation type="unfinished">Изображение не было выбрано</translation> + <translation>Изображение не было выбрано</translation> </message> <message> - <location filename="../ofdscene.cpp" line="56"/> + <location filename="../ofdscene.cpp" line="57"/> <source>Selected image: </source> - <translation type="unfinished"></translation> + <translation>Выбранное изображение: </translation> </message> <message> - <location filename="../ofdscene.cpp" line="115"/> + <location filename="../ofdscene.cpp" line="116"/> <source>Captcha was not solved correctly!</source> - <translation type="unfinished">Капча была решена неверно!</translation> + <translation>Капча была решена неверно!</translation> </message> <message> - <location filename="../ofdscene.cpp" line="117"/> + <location filename="../ofdscene.cpp" line="118"/> <source>Captcha is incorrect</source> - <translation type="unfinished">Капча введена неверно</translation> + <translation>Капча введена неверно</translation> </message> <message> - <location filename="../ofdscene.cpp" line="122"/> + <location filename="../ofdscene.cpp" line="123"/> <source>Internal server error. Please, try again later.</source> - <translation type="unfinished">Внутренняя ошибка сервера. Пожалуйста, попробуйте снова позже.</translation> + <translation>Внутренняя ошибка сервера. Пожалуйста, попробуйте снова позже.</translation> </message> <message> - <location filename="../ofdscene.cpp" line="124"/> + <location filename="../ofdscene.cpp" line="125"/> <source>Internal server error</source> - <translation type="unfinished">Внутренняя ошибка сервера</translation> + <translation>Внутренняя ошибка сервера</translation> </message> <message> - <location filename="../ofdscene.cpp" line="129"/> + <location filename="../ofdscene.cpp" line="130"/> <source>Check not found. Please, ensure correctness of entered data.</source> - <translation type="unfinished">Чек не найден. Пожалуйста, убедитесь в правильности введённых данных.</translation> + <translation>Чек не найден. Пожалуйста, убедитесь в правильности введённых данных.</translation> </message> <message> - <location filename="../ofdscene.cpp" line="131"/> + <location filename="../ofdscene.cpp" line="132"/> <source>Check was not found</source> - <translation type="unfinished">Чек не найден</translation> + <translation>Чек не найден</translation> </message> </context> <context>