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).
This commit is contained in:
Samir Aguiar
2015-01-20 00:02:59 +01:00
parent ae031137b3
commit ce8f49d530
2 changed files with 6 additions and 2 deletions

View File

@@ -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);

View File

@@ -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");