From ce8f49d530eead270eee64cb850b72fae3a6f61e Mon Sep 17 00:00:00 2001 From: Samir Aguiar Date: Tue, 20 Jan 2015 00:02:59 +0100 Subject: [PATCH] localization: Use path relative to the application executable This allows the languages to be loaded when the user is running the app from another directory (e.g. when the app is run from an exported path). --- src/Application.cpp | 4 +++- src/PreferencesDialog.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index 791e3efb..5c746eb5 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -30,7 +30,9 @@ Application::Application(int& argc, char** argv) : // First of all try to load the application translation file. m_translatorApp = new QTranslator(this); - ok = m_translatorApp->load("sqlb_" + name, "translations"); + ok = m_translatorApp->load("sqlb_" + name, + QCoreApplication::applicationDirPath() + "/translations"); + if (ok == true) { PreferencesDialog::setSettingsValue("General", "language", name); installTranslator(m_translatorApp); diff --git a/src/PreferencesDialog.cpp b/src/PreferencesDialog.cpp index 3cd8cca5..41458067 100644 --- a/src/PreferencesDialog.cpp +++ b/src/PreferencesDialog.cpp @@ -265,7 +265,9 @@ void PreferencesDialog::removeExtension() void PreferencesDialog::fillLanguageBox() { - QDir translationsDir("translations", "sqlb_*.qm"); + // Use the path relative to the main executable + QDir translationsDir(QCoreApplication::applicationDirPath() + "/translations", + "sqlb_*.qm"); // Add default language ui->languageComboBox->addItem("English (United States)", "en_US");