Improved language file initialization code.

This commit is contained in:
LoRd_MuldeR 2011-12-18 15:19:07 +01:00
parent 44da665abc
commit 6657745daa
4 changed files with 40 additions and 30 deletions

View File

@ -2289,32 +2289,32 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_MetaInfo.cpp" line="84"/>
<location filename="../../src/Dialog_MetaInfo.cpp" line="87"/>
<source>Meta Information</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_MetaInfo.cpp" line="84"/>
<location filename="../../src/Dialog_MetaInfo.cpp" line="87"/>
<source>The following meta information have been extracted from the original file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_MetaInfo.cpp" line="103"/>
<location filename="../../src/Dialog_MetaInfo.cpp" line="106"/>
<source>Meta Information: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_MetaInfo.cpp" line="157"/>
<location filename="../../src/Dialog_MetaInfo.cpp" line="160"/>
<source>Load Artwork</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_MetaInfo.cpp" line="173"/>
<location filename="../../src/Dialog_MetaInfo.cpp" line="176"/>
<source>Artwork Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_MetaInfo.cpp" line="173"/>
<location filename="../../src/Dialog_MetaInfo.cpp" line="176"/>
<source>Sorry, failed to load artwork from selected file!</source>
<translation type="unfinished"></translation>
</message>

View File

@ -2289,32 +2289,32 @@
<translation type="unfinished">Usuń okładkę</translation>
</message>
<message>
<location filename="../../src/Dialog_MetaInfo.cpp" line="84"/>
<location filename="../../src/Dialog_MetaInfo.cpp" line="87"/>
<source>Meta Information</source>
<translation type="unfinished">Metadane</translation>
</message>
<message>
<location filename="../../src/Dialog_MetaInfo.cpp" line="84"/>
<location filename="../../src/Dialog_MetaInfo.cpp" line="87"/>
<source>The following meta information have been extracted from the original file.</source>
<translation type="unfinished">Następujące metadane zostały wyodrębnione z oryginalnego pliku.</translation>
</message>
<message>
<location filename="../../src/Dialog_MetaInfo.cpp" line="103"/>
<location filename="../../src/Dialog_MetaInfo.cpp" line="106"/>
<source>Meta Information: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_MetaInfo.cpp" line="157"/>
<location filename="../../src/Dialog_MetaInfo.cpp" line="160"/>
<source>Load Artwork</source>
<translation type="unfinished">Załaduj okładkę</translation>
</message>
<message>
<location filename="../../src/Dialog_MetaInfo.cpp" line="173"/>
<location filename="../../src/Dialog_MetaInfo.cpp" line="176"/>
<source>Artwork Error</source>
<translation type="unfinished">Błąd pliku okładki</translation>
</message>
<message>
<location filename="../../src/Dialog_MetaInfo.cpp" line="173"/>
<location filename="../../src/Dialog_MetaInfo.cpp" line="176"/>
<source>Sorry, failed to load artwork from selected file!</source>
<translation type="unfinished">Załadowanie pliku okładki zakończone niepowodzeniem!</translation>
</message>

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 4
#define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 10
#define VER_LAMEXP_BUILD 813
#define VER_LAMEXP_BUILD 816
///////////////////////////////////////////////////////////////////////////////
// Tool versions (minimum expected versions!)

View File

@ -32,6 +32,7 @@
#include <QLibrary>
#include <QResource>
#include <QTime>
#include <QTextStream>
/* helper macros */
#define PRINT_CPU_TYPE(X) case X: qDebug("Selected CPU is: " #X)
@ -245,33 +246,42 @@ void InitializationThread::initTranslations(void)
while(!qmFiles.isEmpty())
{
QString langId, langName;
unsigned int systemId = 0;
QString qmFile = qmFiles.takeFirst();
unsigned int systemId = 0;
QRegExp langIdExp("LameXP_(\\w\\w)\\.qm", Qt::CaseInsensitive);
if(langIdExp.indexIn(qmFile) >= 0)
{
langId = langIdExp.cap(1).toLower();
}
QResource langRes = (QString(":/localization/%1.txt").arg(qmFile));
if(langRes.isValid() && langRes.size() > 0)
{
QStringList langInfo = QString::fromUtf8(reinterpret_cast<const char*>(langRes.data()), langRes.size()).simplified().split(",", QString::SkipEmptyParts);
if(langInfo.count() == 2)
QResource langRes = QResource(QString(":/localization/%1.txt").arg(qmFile));
if(langRes.isValid() && langRes.size() > 0)
{
systemId = langInfo.at(0).toUInt();
langName = langInfo.at(1);
QByteArray data = QByteArray::fromRawData(reinterpret_cast<const char*>(langRes.data()), langRes.size());
QTextStream stream(&data, QIODevice::ReadOnly);
stream.setAutoDetectUnicode(false); stream.setCodec("UTF-8");
while(!stream.atEnd())
{
QStringList langInfo = stream.readLine().simplified().split(",", QString::SkipEmptyParts);
if(langInfo.count() == 2)
{
systemId = langInfo.at(0).trimmed().toUInt();
langName = langInfo.at(1).trimmed();
break;
}
}
}
}
if(lamexp_translation_register(langId, qmFile, langName, systemId))
if(!(langId.isEmpty() || langName.isEmpty() || systemId == 0))
{
qDebug("Registering translation: %s = %s (%u)", qmFile.toUtf8().constData(), langName.toUtf8().constData(), systemId);
}
else
{
qWarning("Failed to register: %s", qmFile.toLatin1().constData());
if(lamexp_translation_register(langId, qmFile, langName, systemId))
{
qDebug("Registering translation: %s = %s (%u)", qmFile.toUtf8().constData(), langName.toUtf8().constData(), systemId);
}
else
{
qWarning("Failed to register: %s", qmFile.toLatin1().constData());
}
}
}