Merge pull request #218 from crumblingstatue/embedded-lang

gui: Embed the language files into the executable
This commit is contained in:
Daniel Marjamäki 2014-01-15 08:37:28 -08:00
commit adc8713ab3
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 RESOURCES = gui.qrc
FORMS = about.ui \ FORMS = about.ui \
application.ui \ application.ui \

View File

@ -32,5 +32,18 @@
<file alias="cfg/posix.cfg">../cfg/posix.cfg</file> <file alias="cfg/posix.cfg">../cfg/posix.cfg</file>
<file alias="cfg/std.cfg">../cfg/std.cfg</file> <file alias="cfg/std.cfg">../cfg/std.cfg</file>
<file alias="cfg/windows.cfg">../cfg/windows.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> </qresource>
</RCC> </RCC>

View File

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