Skip to content

Commit

Permalink
Improved translation support.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaartenBaert committed Dec 27, 2014
1 parent e2bfe64 commit aad4eeb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
17 changes: 12 additions & 5 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,18 @@ int main(int argc, char* argv[]) {
QCoreApplication::setOrganizationName("SimpleScreenRecorder");
QCoreApplication::setApplicationName("SimpleScreenRecorder");

// set the language
QTranslator translator;
if(!translator.load(QLocale::system(), "simplescreenrecorder", "_", QCoreApplication::applicationDirPath()))
translator.load(QLocale::system(), "simplescreenrecorder", "_", GetApplicationSystemDir("translations"));
QApplication::installTranslator(&translator);
// load Qt translations
QTranslator translator_qt;
if(!translator_qt.load(QLocale::system(), "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
//if(!translator_qt.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
qDebug() << "Could not load system translator.";
QApplication::installTranslator(&translator_qt);

// load SSR translations
QTranslator translator_ssr;
if(!translator_ssr.load(QLocale::system(), "simplescreenrecorder", "_", QCoreApplication::applicationDirPath()))
translator_ssr.load(QLocale::system(), "simplescreenrecorder", "_", GetApplicationSystemDir("translations"));
QApplication::installTranslator(&translator_ssr);

// Qt doesn't count hidden windows, so if the main window is hidden and a dialog box is closed, Qt thinks the application should quit.
// That's not what we want, so disable this and do it manually.
Expand Down
16 changes: 8 additions & 8 deletions src/common/Dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ enum_button MessageBox(QMessageBox::Icon icon, QWidget* parent, const QString& t
QPushButton *ptr;
};
ButtonData buttondata[] = {
{BUTTON_OK , QMessageBox::tr("&OK") , QMessageBox::AcceptRole, NULL},
{BUTTON_CANCEL , QMessageBox::tr("&Cancel") , QMessageBox::RejectRole, NULL},
{BUTTON_YES , QMessageBox::tr("&Yes") , QMessageBox::YesRole , NULL},
{BUTTON_YES_ALWAYS, QMessageBox::tr("Yes, always"), QMessageBox::YesRole , NULL},
{BUTTON_NO , QMessageBox::tr("&No") , QMessageBox::NoRole , NULL},
{BUTTON_NO_NEVER , QMessageBox::tr("No, never") , QMessageBox::NoRole , NULL},
{BUTTON_OK , QDialogButtonBox::tr("&OK") , QMessageBox::AcceptRole, NULL},
{BUTTON_CANCEL , QDialogButtonBox::tr("&Cancel") , QMessageBox::RejectRole, NULL},
{BUTTON_YES , QDialogButtonBox::tr("&Yes") , QMessageBox::YesRole , NULL},
{BUTTON_YES_ALWAYS, QDialogButtonBox::tr("Yes, always"), QMessageBox::YesRole , NULL},
{BUTTON_NO , QDialogButtonBox::tr("&No") , QMessageBox::NoRole , NULL},
{BUTTON_NO_NEVER , QDialogButtonBox::tr("No, never") , QMessageBox::NoRole , NULL},
};

// add buttons
Expand Down Expand Up @@ -69,8 +69,8 @@ QString InputBox(QWidget* parent, const QString& title, const QString& text, con

QInputDialog dialog(parent);
dialog.setInputMode(QInputDialog::TextInput);
dialog.setOkButtonText(QMessageBox::tr("&OK"));
dialog.setCancelButtonText(QMessageBox::tr("&Cancel"));
dialog.setOkButtonText(QDialogButtonBox::tr("&OK"));
dialog.setCancelButtonText(QDialogButtonBox::tr("&Cancel"));

dialog.setWindowTitle(title);
dialog.setLabelText(text);
Expand Down

1 comment on commit aad4eeb

@GreenLunar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the commit that fixed issue #280?

Please sign in to comment.