uint o;
};
- enum { Contexts = 0x2f, Hashes = 0x42, Messages = 0x69, NumerusRules = 0x88 };
+ enum { Contexts = 0x2f, Hashes = 0x42, Messages = 0x69, NumerusRules = 0x88, Dependencies = 0x96 };
Releaser() : m_codec(0) {}
void squeeze(TranslatorSaveMode mode);
void setNumerusRules(const QByteArray &rules);
+ void setDependencies(const QStringList &dependencies);
private:
Q_DISABLE_COPY(Releaser)
QByteArray m_contextArray;
QMap<ByteTranslatorMessage, void *> m_messages;
QByteArray m_numerusRules;
+ QStringList m_dependencies;
+ QByteArray m_dependencyArray;
// Used to reproduce the original bytes
QTextCodec *m_codec;
QDataStream s(iod);
s.writeRawData((const char *)magic, MagicLength);
+ if (!m_dependencyArray.isEmpty()) {
+ quint32 das = quint32(m_dependencyArray.size());
+ s << quint8(Dependencies) << das;
+ s.writeRawData(m_dependencyArray.constData(), das);
+ }
if (!m_offsetArray.isEmpty()) {
quint32 oas = quint32(m_offsetArray.size());
s << quint8(Hashes) << oas;
void Releaser::squeeze(TranslatorSaveMode mode)
{
+ m_dependencyArray.clear();
+ QDataStream depstream(&m_dependencyArray, QIODevice::WriteOnly);
+ foreach (const QString &dep, m_dependencies)
+ depstream << dep;
+
if (m_messages.isEmpty() && mode == SaveEverything)
return;
m_numerusRules = rules;
}
+void Releaser::setDependencies(const QStringList &dependencies)
+{
+ m_dependencies = dependencies;
+}
+
static quint8 read8(const uchar *data)
{
return *data;
return false;
}
- enum { Contexts = 0x2f, Hashes = 0x42, Messages = 0x69, NumerusRules = 0x88 };
+ enum { Contexts = 0x2f, Hashes = 0x42, Messages = 0x69, NumerusRules = 0x88, Dependencies = 0x96 };
// for squeezed but non-file data, this is what needs to be deleted
const uchar *messageArray = 0;
} else if (tag == Messages) {
messageArray = data;
//qDebug() << "MESSAGES: " << blockLen << QByteArray((const char *)data, blockLen).toHex();
+ } else if (tag == Dependencies) {
+ QStringList dependencies;
+ QDataStream stream(QByteArray::fromRawData((const char*)data, blockLen));
+ QString dep;
+ while (!stream.atEnd()) {
+ stream >> dep;
+ dependencies.append(dep);
+ }
+ translator.setDependencies(dependencies);
}
data += blockLen;
"Excess context/disambiguation dropped from %n message(s).", 0,
QCoreApplication::DefaultCodec, droppedData));
+ releaser.setDependencies(translator.dependencies());
releaser.squeeze(cd.m_saveMode);
bool saved = releaser.save(&dev);
if (saved && cd.isVerbose()) {
{
STRING(both);
STRING(byte);
+ STRING(catalog);
STRING(comment);
STRING(context);
STRING(defaultcodec);
+ STRING(dependencies);
+ STRING(dependency);
STRING(encoding);
STRING(extracomment);
STRING(filename);
QString tag = name().toString();
translator.setExtra(tag.mid(6), readContents());
// </extra-...>
+ } else if (elementStarts(strdependencies)) {
+ /*
+ * <dependencies>
+ * <dependency catalog="qtsystems_no"/>
+ * <dependency catalog="qtbase_no"/>
+ * </dependencies>
+ **/
+ QStringList dependencies;
+ while (!atEnd()) {
+ readNext();
+ if (isEndElement()) {
+ // </dependencies> found, finish local loop
+ break;
+ } else if (elementStarts(strdependency)) {
+ // <dependency>
+ QXmlStreamAttributes atts = attributes();
+ dependencies.append(atts.value(strcatalog).toString());
+ while (!atEnd()) {
+ readNext();
+ if (isEndElement()) {
+ // </dependency> found, finish local loop
+ break;
+ }
+ }
+ }
+ }
+ translator.setDependencies(dependencies);
} else if (elementStarts(strcontext)) {
// <context>
QString context;
if (codecName != "ISO-8859-1")
t << "<defaultcodec>" << codecName << "</defaultcodec>\n";
+ QStringList deps = translator.dependencies();
+ if (!deps.isEmpty()) {
+ t << "<dependencies>\n";
+ foreach (const QString &dep, deps)
+ t << "<dependency catalog=\"" << dep << "\"/>\n";
+ t << "</dependencies>\n";
+ }
+
QRegExp drops(cd.dropTags().join(QLatin1String("|")));
if (format == 20)
! extra-loc-blank
-->
<!ELEMENT extra-* %evilstring; >
-<!ELEMENT TS (defaultcodec?, extra-**, (context|message)+) >
+<!ELEMENT TS (defaultcodec?, extra-**, dependencies?, (context|message)+) >
<!ATTLIST TS
version CDATA #IMPLIED
sourcelanguage CDATA #IMPLIED
<!ELEMENT context (name, comment?, (context|message)+) >
<!ATTLIST context
encoding CDATA #IMPLIED>
+<!ELEMENT dependencies (dependency+) >
+<!ATTLIST dependency
+ catalog CDATA #IMPLIED>
<!ELEMENT name %evilstring; >
<!-- This is "disambiguation" in the (new) API, or "msgctxt" in gettext speak -->
<!ELEMENT comment %evilstring; >