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

View File

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

View File

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

View File

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