fix: translations are not being installed via make install

This commit is contained in:
schdub
2015-05-12 22:15:10 +03:00
parent b5796d5df7
commit f251d11ccb
5 changed files with 43 additions and 7 deletions

View File

@@ -32,6 +32,10 @@ Application::Application(int& argc, char** argv) :
m_translatorApp = new QTranslator(this);
ok = m_translatorApp->load("sqlb_" + name,
QCoreApplication::applicationDirPath() + "/translations");
// If failed then try to load .qm file from resources
if (ok == false) {
ok = m_translatorApp->load("sqlb_" + name, ":/translations");
}
if (ok == true) {
PreferencesDialog::setSettingsValue("General", "language", name);

View File

@@ -394,6 +394,7 @@ void PreferencesDialog::fillLanguageBox()
"en_US");
}
// append availeble *.qm files from translation dir near executable
foreach(const QFileInfo &file, translationsDir.entryInfoList())
{
QLocale locale(file.baseName().remove("sqlb_"));
@@ -411,6 +412,28 @@ void PreferencesDialog::fillLanguageBox()
ui->languageComboBox->addItem(QIcon(":/flags/" + locale.name()), language, locale.name());
}
// append *.qm files from resources
foreach (const QFileInfo &file, QDir(":/translations").entryInfoList())
{
QLocale locale(file.baseName().remove("sqlb_"));
// Skip invalid locales
if(locale.name() == "C")
continue;
// Translation for this locale already loaded in previous foreach
if (ui->languageComboBox->findData(locale.name(), Qt::UserRole, Qt::MatchExactly) != -1)
continue;
QString language = QLocale::languageToString(locale.language()) + " (" +
QLocale::countryToString(locale.country()) + ")";
if (locale == systemLocale)
language += " [System language]";
ui->languageComboBox->addItem(QIcon(":/flags/" + locale.name()), language, locale.name());
}
ui->languageComboBox->model()->sort(0);
// Try to select the language for the stored locale

View File

@@ -81,7 +81,8 @@ SOURCES += \
FileDialog.cpp
RESOURCES += icons/icons.qrc \
translations/flags/flags.qrc
translations/flags/flags.qrc \
translations/translations.qrc
FORMS += \
MainWindow.ui \

View File

@@ -0,0 +1,8 @@
<RCC>
<qresource prefix="/translations">
<file alias="sqlb_ru">sqlb_ru.qm</file>
<file alias="sqlb_de">sqlb_de.qm</file>
<file alias="sqlb_fr">sqlb_fr.qm</file>
<file alias="sqlb_zh">sqlb_zh.qm</file>
</qresource>
</RCC>