Skip to content

Commit 5be4668

Browse files
Fix translation issues and add new macro
1 parent 1712108 commit 5be4668

File tree

5 files changed

+33
-105
lines changed

5 files changed

+33
-105
lines changed

src/GUI/HotkeysMainWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void HotkeysMainWindow::SetGameObjectList(const QString& factionShortName)
211211
{
212212
// Create new section of tree list
213213
QTreeWidgetItem* newTopEntityItem = new QTreeWidgetItem();
214-
newTopEntityItem->setText(0, QCoreApplication::translate("QObject", PROGRAM_CONSTANTS->INGAME_ENTITIES_STRINGS.value(objectType).toUtf8().constData()));
214+
newTopEntityItem->setText(0, L10N(PROGRAM_CONSTANTS->INGAME_ENTITIES_STRINGS.value(objectType)));
215215

216216
// Decorate
217217
newTopEntityItem->setIcon(0, ImageManager::GetGameObjectTypePixmap(objectType)

src/GUI/Translations/ru.ts

Lines changed: 14 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -285,45 +285,6 @@
285285
<translation type="vanished">&lt;a href=&quot;https://github.com/MahBoiDeveloper/GZHHotkeysEditor&quot;&gt;Репозиторий на GitHub&lt;/a&gt;</translation>
286286
</message>
287287
</context>
288-
<context>
289-
<name>LoadDialog</name>
290-
<message>
291-
<source>START</source>
292-
<translation type="vanished">НАЧАТЬ</translation>
293-
</message>
294-
<message>
295-
<source>BACK</source>
296-
<translation type="vanished">НАЗАД</translation>
297-
</message>
298-
<message>
299-
<source>Text files</source>
300-
<translation type="vanished">Текстовые файлы</translation>
301-
</message>
302-
<message>
303-
<source>Any files</source>
304-
<translation type="vanished">Все файлы</translation>
305-
</message>
306-
<message>
307-
<source>REVIEW</source>
308-
<translation type="vanished">ОБЗОР</translation>
309-
</message>
310-
<message>
311-
<source>LOAD PROJECT</source>
312-
<translation type="vanished">ЗАГРУЗИТЬ ПРОЕКТ</translation>
313-
</message>
314-
<message>
315-
<source>Review</source>
316-
<translation type="vanished">Обзор</translation>
317-
</message>
318-
<message>
319-
<source>Load project</source>
320-
<translation type="vanished">Загрузить проект</translation>
321-
</message>
322-
<message>
323-
<source>Load installed game hotkey map</source>
324-
<translation type="vanished">Загрузить горячие клавиши из игры</translation>
325-
</message>
326-
</context>
327288
<context>
328289
<name>LoadFromTheFileWindow</name>
329290
<message>
@@ -384,108 +345,71 @@
384345
<translation>Сохранять горячие клавиши в игре.</translation>
385346
</message>
386347
</context>
387-
<context>
388-
<name>LoadWindow</name>
389-
<message>
390-
<source>START</source>
391-
<translation type="obsolete">НАЧАТЬ</translation>
392-
</message>
393-
<message>
394-
<source>BACK</source>
395-
<translation type="obsolete">НАЗАД</translation>
396-
</message>
397-
<message>
398-
<source>Text files</source>
399-
<translation type="obsolete">Текстовые файлы</translation>
400-
</message>
401-
<message>
402-
<source>Any files</source>
403-
<translation type="obsolete">Все файлы</translation>
404-
</message>
405-
<message>
406-
<source>REVIEW</source>
407-
<translation type="obsolete">ОБЗОР</translation>
408-
</message>
409-
<message>
410-
<source>Load project</source>
411-
<translation type="obsolete">Загрузить проект</translation>
412-
</message>
413-
<message>
414-
<source>Load installed game hotkey map</source>
415-
<translation type="obsolete">Загрузить горячие клавиши из игры</translation>
416-
</message>
417-
</context>
418348
<context>
419349
<name>QObject</name>
420350
<message>
421-
<location filename="../../ProgramConstants.hpp" line="71"/>
422351
<source>Unable to find Settings.json in Resource folder.</source>
423-
<translation>Невозможно найти файл Settings.json в папке Resources.</translation>
352+
<translation type="vanished">Невозможно найти файл Settings.json в папке Resources.</translation>
424353
</message>
425354
<message>
426-
<location filename="../../ProgramConstants.hpp" line="72"/>
427355
<source>Unable to find TechTree.json in Resource folder.</source>
428-
<translation>Невозможно найти файл TechTree.json в папке Resources.</translation>
356+
<translation type="vanished">Невозможно найти файл TechTree.json в папке Resources.</translation>
429357
</message>
430358
<message>
431-
<location filename="../../ProgramConstants.hpp" line="73"/>
432359
<source>Unable to find Resource/Theme folder.</source>
433-
<translation>Невозможно найти папку Resource/Theme.</translation>
360+
<translation type="vanished">Невозможно найти папку Resource/Theme.</translation>
434361
</message>
435362
<message>
436-
<location filename="../../ProgramConstants.hpp" line="74"/>
437363
<source>Unable to find Resource/Icons folder.</source>
438-
<translation>Невозможно найти папку Resource/Icons.</translation>
364+
<translation type="vanished">Невозможно найти папку Resource/Icons.</translation>
439365
</message>
440366
<message>
441-
<location filename="../../ProgramConstants.hpp" line="75"/>
442367
<source>Unable to find Resource/Translations folder.</source>
443-
<translation>Невозможно найти папку Resource/Translations.</translation>
368+
<translation type="vanished">Невозможно найти папку Resource/Translations.</translation>
444369
</message>
445370
<message>
446-
<location filename="../../ProgramConstants.hpp" line="76"/>
447371
<source>Unknown error has been occured.</source>
448-
<translation>Возникла неизвестная ошибка</translation>
372+
<translation type="vanished">Возникла неизвестная ошибка</translation>
449373
</message>
450374
<message>
451-
<location filename="../../ProgramConstants.hpp" line="77"/>
375+
<location filename="../../ProgramConstants.hpp" line="79"/>
452376
<source>Error with CSF file</source>
453377
<translation>Ошибка с CSF файлом</translation>
454378
</message>
455379
<message>
456-
<location filename="../../ProgramConstants.hpp" line="78"/>
380+
<location filename="../../ProgramConstants.hpp" line="80"/>
457381
<source>Cannot process the empty file.</source>
458382
<translation>Невозможно обработать пустой файл.</translation>
459383
</message>
460384
<message>
461-
<location filename="../../ProgramConstants.hpp" line="79"/>
385+
<location filename="../../ProgramConstants.hpp" line="81"/>
462386
<source>Unable to find selected CSF file.</source>
463387
<translation>Невозможно найти указанный CSF файл.</translation>
464388
</message>
465389
<message>
466-
<location filename="../../ProgramConstants.hpp" line="80"/>
390+
<location filename="../../ProgramConstants.hpp" line="82"/>
467391
<source>Choosen CSF file doesn&apos;t have CONTROLBAR category.
468392
Make sure that you are load correct file.</source>
469393
<translation>У выбранного CSF файла отсутствует категория CONTROLBAR
470394
Проверьте, что вы загружаете правильный файл.</translation>
471395
</message>
472396
<message>
473-
<location filename="../../ProgramConstants.hpp" line="110"/>
397+
<location filename="../../ProgramConstants.hpp" line="112"/>
474398
<source>Buildings</source>
475399
<translation>Здания</translation>
476400
</message>
477401
<message>
478-
<location filename="../../ProgramConstants.hpp" line="111"/>
402+
<location filename="../../ProgramConstants.hpp" line="113"/>
479403
<source>Infantry</source>
480404
<translation>Пехота</translation>
481405
</message>
482406
<message>
483-
<location filename="../../ProgramConstants.hpp" line="112"/>
407+
<location filename="../../ProgramConstants.hpp" line="114"/>
484408
<source>Vehicles</source>
485409
<translation>Техника</translation>
486410
</message>
487411
<message>
488-
<location filename="../../ProgramConstants.hpp" line="113"/>
412+
<location filename="../../ProgramConstants.hpp" line="115"/>
489413
<source>Aircrafts</source>
490414
<translation>Авиация</translation>
491415
</message>

src/GUI/WindowManager.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,24 @@ void WindowManager::LaunchWidget_AcceptConfiguration()
4545

4646
if (strCSFFilePath == "")
4747
{
48-
QMessageBox::critical(nullptr, PROGRAM_CONSTANTS->CSF_ERROR_HEADER, PROGRAM_CONSTANTS->CSF_EMPTY_STRING_ERROR);
48+
QMessageBox::critical(nullptr, L10N(PROGRAM_CONSTANTS->CSF_ERROR_HEADER),
49+
L10N(PROGRAM_CONSTANTS->CSF_EMPTY_STRING_ERROR));
4950
return;
5051
}
5152

5253
if (!QFile::exists(strCSFFilePath))
5354
{
54-
QMessageBox::critical(nullptr, PROGRAM_CONSTANTS->CSF_ERROR_HEADER, PROGRAM_CONSTANTS->CSF_DOESNTEXIST_ERROR);
55+
QMessageBox::critical(nullptr, L10N(PROGRAM_CONSTANTS->CSF_ERROR_HEADER),
56+
L10N(PROGRAM_CONSTANTS->CSF_DOESNT_EXIST_ERROR));
5557
return;
5658
}
5759

5860
CSF_PARSER = std::make_unique<CSFParser>(strCSFFilePath);
5961

6062
if (!CSF_PARSER->ExistCategory(PROGRAM_CONSTANTS->HOTKEY_CSF_CATEGORY))
6163
{
62-
QMessageBox::critical(nullptr, PROGRAM_CONSTANTS->CSF_ERROR_HEADER, PROGRAM_CONSTANTS->CSF_NOCTLBAR_ERROR);
64+
QMessageBox::critical(nullptr, L10N(PROGRAM_CONSTANTS->CSF_ERROR_HEADER),
65+
L10N(PROGRAM_CONSTANTS->CSF_NO_CTLBAR_ERROR));
6366
return;
6467
}
6568

src/Main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
using namespace std;
1919

20-
int ShowErrorMessage(const char* txt)
20+
int ShowErrorMessage(const QString& txt)
2121
{
2222
// Log exception message
23-
LOGGER->LogException(txt);
23+
LOGGER->LogException(txt.toUtf8().constData());
2424

2525
// And show it to user
2626
QMessageBox::critical(nullptr, LOGGER->EXCEPTION_HEADER, txt);

src/ProgramConstants.hpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#include <QPair>
66
#include <QSize>
77
#include <QObject>
8-
#include <QTranslator>
98

109
#include "Settings.hpp"
1110

11+
#define L10N(x) QCoreApplication::translate("QObject",x.toUtf8().constData())
1212
#define PROGRAM_CONSTANTS ProgramConstants::Instance
1313

1414
enum class GameObjectTypes
@@ -69,16 +69,17 @@ class ProgramConstants
6969
const int EMPTY_KEY_WIDTH = 25;
7070

7171
// Errors
72-
const char* SETTINGS_NO_FOUND = QObject::tr("Unable to find Settings.json in Resource folder.").toStdString().c_str();
73-
const char* TECH_TREE_NO_FOUND = QObject::tr("Unable to find TechTree.json in Resource folder.").toStdString().c_str();
74-
const char* THEME_FOLDER_NO_FOUND = QObject::tr("Unable to find Resource/Theme folder.").toStdString().c_str();
75-
const char* ICONS_FOLDER_NO_FOUND = QObject::tr("Unable to find Resource/Icons folder.").toStdString().c_str();
76-
const char* TRANSLATIONS_NO_FOUND = QObject::tr("Unable to find Resource/Translations folder.").toStdString().c_str();
77-
const char* UNKNOWN_ERROR = QObject::tr("Unknown error has been occured.").toStdString().c_str();
72+
const char* SETTINGS_NO_FOUND = "Unable to find Settings.json in Resource folder.";
73+
const char* TECH_TREE_NO_FOUND = "Unable to find TechTree.json in Resource folder.";
74+
const char* THEME_FOLDER_NO_FOUND = "Unable to find Resource/Theme folder.";
75+
const char* ICONS_FOLDER_NO_FOUND = "Unable to find Resource/Icons folder.";
76+
const char* TRANSLATIONS_NO_FOUND = "Unable to find Resource/Translations folder.";
77+
const char* UNKNOWN_ERROR = "Unknown error has been occured.";
78+
7879
const QString CSF_ERROR_HEADER = QObject::tr("Error with CSF file");
7980
const QString CSF_EMPTY_STRING_ERROR = QObject::tr("Cannot process the empty file.");
80-
const QString CSF_DOESNTEXIST_ERROR = QObject::tr("Unable to find selected CSF file.");
81-
const QString CSF_NOCTLBAR_ERROR = QObject::tr("Choosen CSF file doesn't have CONTROLBAR category.\nMake sure that you are load correct file.");
81+
const QString CSF_DOESNT_EXIST_ERROR = QObject::tr("Unable to find selected CSF file.");
82+
const QString CSF_NO_CTLBAR_ERROR = QObject::tr("Choosen CSF file doesn't have CONTROLBAR category.\nMake sure that you are load correct file.");
8283

8384
// Other constants
8485
const QString HOTKEY_CSF_CATEGORY = "CONTROLBAR";

0 commit comments

Comments
 (0)