Skip to content

Commit

Permalink
Add Hebrew translation for the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
IgKh committed Jan 20, 2024
1 parent 04fd920 commit bb43a46
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
find_package(Qt6 REQUIRED COMPONENTS Widgets PdfWidgets)
find_package(Qt6 REQUIRED COMPONENTS Widgets PdfWidgets LinguistTools)

qt_standard_project_setup()

Expand Down Expand Up @@ -40,3 +40,7 @@ set_target_properties(katvan PROPERTIES
WIN32_EXECUTABLE ON
MACOSX_BUNDLE ON
)

qt_add_translations(katvan TS_FILES
translations/katvan_he.ts
)
2 changes: 1 addition & 1 deletion src/katvan_mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ bool MainWindow::maybeSave()
QMessageBox::StandardButton res = QMessageBox::warning(
this,
QCoreApplication::applicationName(),
tr("The file %1 has been modified.\nDo you want to save your changes").arg(d_currentFileShortName),
tr("The file %1 has been modified.\nDo you want to save your changes?").arg(d_currentFileShortName),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);

if (res == QMessageBox::Save) {
Expand Down
20 changes: 20 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include <QApplication>
#include <QCommandLineParser>
#include <QLibraryInfo>
#include <QTranslator>

int main(int argc, char** argv)
{
Expand All @@ -28,12 +30,30 @@ int main(int argc, char** argv)
QCoreApplication::setApplicationName("Katvan");
QCoreApplication::setApplicationVersion(katvan::KATVAN_VERSION + "-" + katvan::KATVAN_GIT_SHA);

QCommandLineOption forceHebrewUI("heb", "Force Hebrew UI");

QCommandLineParser parser;
parser.addPositionalArgument("file", "File to open");
parser.addOption(forceHebrewUI);
parser.addVersionOption();
parser.addHelpOption();
parser.process(app);

QLocale locale = QLocale::system();
if (parser.isSet(forceHebrewUI)) {
locale = QLocale(QLocale::Hebrew);
}

QTranslator translator;
if (translator.load(locale, "katvan", "_", ":/i18n")) {
QCoreApplication::installTranslator(&translator);
}

QTranslator qtTranslator;
if (qtTranslator.load(locale, "qtbase", "_", QLibraryInfo::path(QLibraryInfo::TranslationsPath))) {
app.installTranslator(&qtTranslator);
}

katvan::MainWindow wnd;
wnd.show();

Expand Down

0 comments on commit bb43a46

Please sign in to comment.