gui: Embed the language files into the executable

This allows for:
- Out-of-source builds
- Easy installation
This commit is contained in:
Mika Attila 2014-01-15 14:35:26 +01:00
parent d43191a9e3
commit 6a97da9871
3 changed files with 17 additions and 1 deletions

View File

@ -40,6 +40,9 @@ win32 {
}
}
# Generate the translations before we embed them
system("lrelease gui.pro")
RESOURCES = gui.qrc
FORMS = about.ui \
application.ui \

View File

@ -32,5 +32,18 @@
<file alias="cfg/posix.cfg">../cfg/posix.cfg</file>
<file alias="cfg/std.cfg">../cfg/std.cfg</file>
<file alias="cfg/windows.cfg">../cfg/windows.cfg</file>
<file>cppcheck_de.qm</file>
<file>cppcheck_es.qm</file>
<file>cppcheck_fi.qm</file>
<file>cppcheck_fr.qm</file>
<file>cppcheck_it.qm</file>
<file>cppcheck_ja.qm</file>
<file>cppcheck_ko.qm</file>
<file>cppcheck_nl.qm</file>
<file>cppcheck_ru.qm</file>
<file>cppcheck_sr.qm</file>
<file>cppcheck_sv.qm</file>
<file>cppcheck_zh_CN.qm</file>
</qresource>
</RCC>

View File

@ -97,7 +97,7 @@ bool TranslationHandler::SetLanguage(const QString &code)
mTranslator = new QTranslator(this);
//Load the new language
QString translationFile = "lang/" + mTranslations[index].mFilename;
QString translationFile = ":/" + mTranslations[index].mFilename;
if (!mTranslator->load(translationFile) && !failure) {
translationFile += ".qm";
//If it failed, lets check if the default file exists