Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qm.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#include "translator.h"
5
6#ifndef QT_BOOTSTRAPPED
7#include <QtCore/QCoreApplication>
8#endif
9#include <QtCore/QDataStream>
10#include <QtCore/QDebug>
11#include <QtCore/QDir>
12#include <QtCore/QFile>
13#include <QtCore/QFileInfo>
14#include <QtCore/QMap>
15#include <QtCore/QString>
16#include <QtCore/QStringDecoder>
17
19
20using namespace Qt::Literals::StringLiterals;
21
22// magic number for the file
23static const int MagicLength = 16;
24static const uchar magic[MagicLength] = {
25 0x3c, 0xb8, 0x64, 0x18, 0xca, 0xef, 0x9c, 0x95,
26 0xcd, 0x21, 0x1c, 0xbf, 0x60, 0xa1, 0xbd, 0xdd
27};
28
29
30namespace {
31
32enum Tag {
33 Tag_End = 1,
36 Tag_Context16 = 4,
37 Tag_Obsolete1 = 5,
39 Tag_Context = 7,
40 Tag_Comment = 8,
42};
43
44enum Prefix {
45 NoPrefix,
46 Hash,
47 HashContext,
48 HashContextSourceText,
49 HashContextSourceTextComment
50};
51
52} // namespace anon
53
54static uint elfHash(const QByteArray &ba)
55{
56 const uchar *k = (const uchar *)ba.data();
57 uint h = 0;
58 uint g;
59
60 if (k) {
61 while (*k) {
62 h = (h << 4) + *k++;
63 if ((g = (h & 0xf0000000)) != 0)
64 h ^= g >> 24;
65 h &= ~g;
66 }
67 }
68 if (!h)
69 h = 1;
70 return h;
71}
72
74{
75public:
77 const QByteArray &context,
78 const QByteArray &sourceText,
79 const QByteArray &comment,
80 const QStringList &translations) :
85 {}
86 const QByteArray &context() const { return m_context; }
87 const QByteArray &sourceText() const { return m_sourcetext; }
88 const QByteArray &comment() const { return m_comment; }
89 const QStringList &translations() const { return m_translations; }
90 bool operator<(const ByteTranslatorMessage& m) const;
91
92private:
93 QByteArray m_context;
94 QByteArray m_sourcetext;
95 QByteArray m_comment;
96 QStringList m_translations;
97};
98
100
102{
103 if (m_context != m.m_context)
104 return m_context < m.m_context;
105 if (m_sourcetext != m.m_sourcetext)
106 return m_sourcetext < m.m_sourcetext;
107 return m_comment < m.m_comment;
108}
109
111{
112public:
113 struct Offset {
115 : h(0), o(0)
116 {}
117 Offset(uint hash, uint offset)
118 : h(hash), o(offset)
119 {}
120
121 bool operator<(const Offset &other) const {
122 return (h != other.h) ? h < other.h : o < other.o;
123 }
124 bool operator==(const Offset &other) const {
125 return h == other.h && o == other.o;
126 }
129 };
130
131 enum { Contexts = 0x2f, Hashes = 0x42, Messages = 0x69, NumerusRules = 0x88, Dependencies = 0x96, Language = 0xa7 };
132
133 Releaser(const QString &language) : m_language(language) {}
134
135 bool save(QIODevice *iod);
136
137 void insert(const TranslatorMessage &msg, const QStringList &tlns, bool forceComment);
138 void insertIdBased(const TranslatorMessage &message, const QStringList &tlns);
139
141
142 void setNumerusRules(const QByteArray &rules);
143 void setDependencies(const QStringList &dependencies);
144
145private:
147
148 // This should reproduce the byte array fetched from the source file, which
149 // on turn should be the same as passed to the actual tr(...) calls
150 QByteArray originalBytes(const QString &str) const;
151
152 static Prefix commonPrefix(const ByteTranslatorMessage &m1, const ByteTranslatorMessage &m2);
153
154 static uint msgHash(const ByteTranslatorMessage &msg);
155
156 void writeMessage(const ByteTranslatorMessage & msg, QDataStream & stream,
157 TranslatorSaveMode strip, Prefix prefix) const;
158
159 QString m_language;
160 // for squeezed but non-file data, this is what needs to be deleted
161 QByteArray m_messageArray;
162 QByteArray m_offsetArray;
163 QByteArray m_contextArray;
164 QMap<ByteTranslatorMessage, void *> m_messages;
165 QByteArray m_numerusRules;
166 QStringList m_dependencies;
167 QByteArray m_dependencyArray;
168};
169
170QByteArray Releaser::originalBytes(const QString &str) const
171{
172 if (str.isEmpty()) {
173 // Do not use QByteArray() here as the result of the serialization
174 // will be different.
175 return QByteArray("");
176 }
177 return str.toUtf8();
178}
179
180uint Releaser::msgHash(const ByteTranslatorMessage &msg)
181{
182 return elfHash(msg.sourceText() + msg.comment());
183}
184
185Prefix Releaser::commonPrefix(const ByteTranslatorMessage &m1, const ByteTranslatorMessage &m2)
186{
187 if (msgHash(m1) != msgHash(m2))
188 return NoPrefix;
189 if (m1.context() != m2.context())
190 return Hash;
191 if (m1.sourceText() != m2.sourceText())
192 return HashContext;
193 if (m1.comment() != m2.comment())
194 return HashContextSourceText;
195 return HashContextSourceTextComment;
196}
197
198void Releaser::writeMessage(const ByteTranslatorMessage &msg, QDataStream &stream,
199 TranslatorSaveMode mode, Prefix prefix) const
200{
201 for (int i = 0; i < msg.translations().size(); ++i)
202 stream << quint8(Tag_Translation) << msg.translations().at(i);
203
204 if (mode == SaveEverything)
205 prefix = HashContextSourceTextComment;
206
207 // lrelease produces "wrong" QM files for QByteArrays that are .isNull().
208 switch (prefix) {
209 default:
210 case HashContextSourceTextComment:
211 stream << quint8(Tag_Comment) << msg.comment();
212 Q_FALLTHROUGH();
213 case HashContextSourceText:
214 stream << quint8(Tag_SourceText) << msg.sourceText();
215 Q_FALLTHROUGH();
216 case HashContext:
217 stream << quint8(Tag_Context) << msg.context();
218 break;
219 }
220
221 stream << quint8(Tag_End);
222}
223
224
225bool Releaser::save(QIODevice *iod)
226{
227 QDataStream s(iod);
228 s.writeRawData((const char *)magic, MagicLength);
229
230 if (!m_language.isEmpty()) {
231 QByteArray lang = originalBytes(m_language);
232 quint32 las = quint32(lang.size());
233 s << quint8(Language) << las;
234 s.writeRawData(lang, las);
235 }
236 if (!m_dependencyArray.isEmpty()) {
237 quint32 das = quint32(m_dependencyArray.size());
238 s << quint8(Dependencies) << das;
239 s.writeRawData(m_dependencyArray.constData(), das);
240 }
241 if (!m_offsetArray.isEmpty()) {
242 quint32 oas = quint32(m_offsetArray.size());
243 s << quint8(Hashes) << oas;
244 s.writeRawData(m_offsetArray.constData(), oas);
245 }
246 if (!m_messageArray.isEmpty()) {
247 quint32 mas = quint32(m_messageArray.size());
248 s << quint8(Messages) << mas;
249 s.writeRawData(m_messageArray.constData(), mas);
250 }
251 if (!m_contextArray.isEmpty()) {
252 quint32 cas = quint32(m_contextArray.size());
253 s << quint8(Contexts) << cas;
254 s.writeRawData(m_contextArray.constData(), cas);
255 }
256 if (!m_numerusRules.isEmpty()) {
257 quint32 nrs = m_numerusRules.size();
258 s << quint8(NumerusRules) << nrs;
259 s.writeRawData(m_numerusRules.constData(), nrs);
260 }
261 return true;
262}
263
265{
266 m_dependencyArray.clear();
267 QDataStream depstream(&m_dependencyArray, QIODevice::WriteOnly);
268 for (const QString &dep : std::as_const(m_dependencies))
269 depstream << dep;
270
271 if (m_messages.isEmpty() && mode == SaveEverything)
272 return;
273
274 const auto messages = m_messages;
275
276 // re-build contents
277 m_messageArray.clear();
278 m_offsetArray.clear();
279 m_contextArray.clear();
280 m_messages.clear();
281
282 QMap<Offset, void *> offsets;
283
284 QDataStream ms(&m_messageArray, QIODevice::WriteOnly);
285 int cpPrev = 0, cpNext = 0;
286 for (auto it = messages.cbegin(), end = messages.cend(); it != end; ++it) {
287 cpPrev = cpNext;
288 const auto next = std::next(it);
289 if (next == end)
290 cpNext = 0;
291 else
292 cpNext = commonPrefix(it.key(), next.key());
293 offsets.insert(Offset(msgHash(it.key()), ms.device()->pos()), (void *)0);
294 writeMessage(it.key(), ms, mode, Prefix(qMax(cpPrev, cpNext + 1)));
295 }
296
297 auto offset = offsets.cbegin();
298 QDataStream ds(&m_offsetArray, QIODevice::WriteOnly);
299 while (offset != offsets.cend()) {
300 Offset k = offset.key();
301 ++offset;
302 ds << quint32(k.h) << quint32(k.o);
303 }
304
305 if (mode == SaveStripped) {
306 QMap<QByteArray, int> contextSet;
307 for (auto it = messages.cbegin(), end = messages.cend(); it != end; ++it)
308 ++contextSet[it.key().context()];
309
310 quint16 hTableSize;
311 if (contextSet.size() < 200)
312 hTableSize = (contextSet.size() < 60) ? 151 : 503;
313 else if (contextSet.size() < 2500)
314 hTableSize = (contextSet.size() < 750) ? 1511 : 5003;
315 else
316 hTableSize = (contextSet.size() < 10000) ? 15013 : 3 * contextSet.size() / 2;
317
318 QMultiMap<int, QByteArray> hashMap;
319 for (auto c = contextSet.cbegin(), end = contextSet.cend(); c != end; ++c)
320 hashMap.insert(elfHash(c.key()) % hTableSize, c.key());
321
322 /*
323 The contexts found in this translator are stored in a hash
324 table to provide fast lookup. The context array has the
325 following format:
326
327 quint16 hTableSize;
328 quint16 hTable[hTableSize];
329 quint8 contextPool[...];
330
331 The context pool stores the contexts as Pascal strings:
332
333 quint8 len;
334 quint8 data[len];
335
336 Let's consider the look-up of context "FunnyDialog". A
337 hash value between 0 and hTableSize - 1 is computed, say h.
338 If hTable[h] is 0, "FunnyDialog" is not covered by this
339 translator. Else, we check in the contextPool at offset
340 2 * hTable[h] to see if "FunnyDialog" is one of the
341 contexts stored there, until we find it or we meet the
342 empty string.
343 */
344 m_contextArray.resize(2 + (hTableSize << 1));
345 QDataStream t(&m_contextArray, QIODevice::WriteOnly);
346
347 quint16 *hTable = new quint16[hTableSize];
348 memset(hTable, 0, hTableSize * sizeof(quint16));
349
350 t << hTableSize;
351 t.device()->seek(2 + (hTableSize << 1));
352 t << quint16(0); // the entry at offset 0 cannot be used
353 uint upto = 2;
354
355 auto entry = hashMap.constBegin();
356 while (entry != hashMap.constEnd()) {
357 int i = entry.key();
358 hTable[i] = quint16(upto >> 1);
359
360 do {
361 const char *con = entry.value().constData();
362 uint len = uint(entry.value().size());
363 len = qMin(len, 255u);
364 t << quint8(len);
365 t.writeRawData(con, len);
366 upto += 1 + len;
367 ++entry;
368 } while (entry != hashMap.constEnd() && entry.key() == i);
369 if (upto & 0x1) {
370 // offsets have to be even
371 t << quint8(0); // empty string
372 ++upto;
373 }
374 }
375 t.device()->seek(2);
376 for (int j = 0; j < hTableSize; j++)
377 t << hTable[j];
378 delete [] hTable;
379
380 if (upto > 131072) {
381 qWarning("Releaser::squeeze: Too many contexts");
382 m_contextArray.clear();
383 }
384 }
385}
386
387void Releaser::insert(const TranslatorMessage &message, const QStringList &tlns, bool forceComment)
388{
389 ByteTranslatorMessage bmsg(originalBytes(message.context()),
390 originalBytes(message.sourceText()),
391 originalBytes(message.comment()),
392 tlns);
393 if (!forceComment) {
395 bmsg.context(), bmsg.sourceText(), QByteArray(""), bmsg.translations());
396 if (!m_messages.contains(bmsg2)) {
397 m_messages.insert(bmsg2, 0);
398 return;
399 }
400 }
401 m_messages.insert(bmsg, 0);
402}
403
404void Releaser::insertIdBased(const TranslatorMessage &message, const QStringList &tlns)
405{
406 ByteTranslatorMessage bmsg("", originalBytes(message.id()), "", tlns);
407 m_messages.insert(bmsg, 0);
408}
409
410void Releaser::setNumerusRules(const QByteArray &rules)
411{
412 m_numerusRules = rules;
413}
414
415void Releaser::setDependencies(const QStringList &dependencies)
416{
417 m_dependencies = dependencies;
418}
419
420static quint8 read8(const uchar *data)
421{
422 return *data;
423}
424
425static quint32 read32(const uchar *data)
426{
427 return (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | (data[3]);
428}
429
430static void fromBytes(const char *str, int len, QString *out, bool *utf8Fail)
431{
432 QStringDecoder toUnicode(QStringDecoder::Utf8, QStringDecoder::Flag::Stateless);
433 *out = toUnicode(QByteArrayView(str, len));
434 *utf8Fail = toUnicode.hasError();
435}
436
437bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd)
438{
439 QByteArray ba = dev.readAll();
440 const uchar *data = (uchar*)ba.data();
441 int len = ba.size();
442 if (len < MagicLength || memcmp(data, magic, MagicLength) != 0) {
443 cd.appendError("QM-Format error: magic marker missing"_L1);
444 return false;
445 }
446
447 enum { Contexts = 0x2f, Hashes = 0x42, Messages = 0x69, NumerusRules = 0x88, Dependencies = 0x96, Language = 0xa7 };
448
449 // for squeezed but non-file data, this is what needs to be deleted
450 const uchar *messageArray = nullptr;
451 const uchar *offsetArray = nullptr;
452 uint offsetLength = 0;
453
454 bool ok = true;
455 bool utf8Fail = false;
456 const uchar *end = data + len;
457
458 data += MagicLength;
459
460 while (data < end - 4) {
461 quint8 tag = read8(data++);
462 quint32 blockLen = read32(data);
463 //qDebug() << "TAG:" << tag << "BLOCKLEN:" << blockLen;
464 data += 4;
465 if (!tag || !blockLen)
466 break;
467 if (data + blockLen > end) {
468 ok = false;
469 break;
470 }
471
472 if (tag == Hashes) {
473 offsetArray = data;
474 offsetLength = blockLen;
475 //qDebug() << "HASHES: " << blockLen << QByteArray((const char *)data, blockLen).toHex();
476 } else if (tag == Messages) {
477 messageArray = data;
478 //qDebug() << "MESSAGES: " << blockLen << QByteArray((const char *)data, blockLen).toHex();
479 } else if (tag == Dependencies) {
480 QStringList dependencies;
481 QDataStream stream(QByteArray::fromRawData((const char*)data, blockLen));
482 QString dep;
483 while (!stream.atEnd()) {
484 stream >> dep;
485 dependencies.append(dep);
486 }
487 translator.setDependencies(dependencies);
488 } else if (tag == Language) {
489 QString language;
490 fromBytes((const char *)data, blockLen, &language, &utf8Fail);
491 translator.setLanguageCode(language);
492 }
493
494 data += blockLen;
495 }
496
497
498 size_t numItems = offsetLength / (2 * sizeof(quint32));
499 //qDebug() << "NUMITEMS: " << numItems;
500
501 QString strProN = "%n"_L1;
502 QLocale::Language l;
503 QLocale::Territory c;
504 Translator::languageAndTerritory(translator.languageCode(), &l, &c);
505 QStringList numerusForms;
506 bool guessPlurals = true;
507 if (getNumerusInfo(l, c, 0, &numerusForms, 0))
508 guessPlurals = (numerusForms.size() == 1);
509
510 QString context, sourcetext, comment;
511 QStringList translations;
512
513 for (const uchar *start = offsetArray; start != offsetArray + (numItems << 3); start += 8) {
514 //quint32 hash = read32(start);
515 quint32 ro = read32(start + 4);
516 //qDebug() << "\nHASH:" << hash;
517 const uchar *m = messageArray + ro;
518
519 for (;;) {
520 uchar tag = read8(m++);
521 //qDebug() << "Tag:" << tag << " ADDR: " << m;
522 switch(tag) {
523 case Tag_End:
524 goto end;
525 case Tag_Translation: {
526 int len = read32(m);
527 m += 4;
528
529 // -1 indicates an empty string
530 // Otherwise streaming format is UTF-16 -> 2 bytes per character
531 if ((len != -1) && (len & 1)) {
532 cd.appendError("QM-Format error"_L1);
533 return false;
534 }
535 QString str;
536 if (len != -1)
537 str = QString((const QChar *)m, len / 2);
538 if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
539 for (int i = 0; i < str.size(); ++i)
540 str[i] = QChar((str.at(i).unicode() >> 8) +
541 ((str.at(i).unicode() << 8) & 0xff00));
542 }
543 translations << str;
544 m += len;
545 break;
546 }
547 case Tag_Obsolete1:
548 m += 4;
549 //qDebug() << "OBSOLETE";
550 break;
551 case Tag_SourceText: {
552 quint32 len = read32(m);
553 m += 4;
554 //qDebug() << "SOURCE LEN: " << len;
555 //qDebug() << "SOURCE: " << QByteArray((const char*)m, len);
556 fromBytes((const char*)m, len, &sourcetext, &utf8Fail);
557 m += len;
558 break;
559 }
560 case Tag_Context: {
561 quint32 len = read32(m);
562 m += 4;
563 //qDebug() << "CONTEXT LEN: " << len;
564 //qDebug() << "CONTEXT: " << QByteArray((const char*)m, len);
565 fromBytes((const char*)m, len, &context, &utf8Fail);
566 m += len;
567 break;
568 }
569 case Tag_Comment: {
570 quint32 len = read32(m);
571 m += 4;
572 //qDebug() << "COMMENT LEN: " << len;
573 //qDebug() << "COMMENT: " << QByteArray((const char*)m, len);
574 fromBytes((const char*)m, len, &comment, &utf8Fail);
575 m += len;
576 break;
577 }
578 default:
579 //qDebug() << "UNKNOWN TAG" << tag;
580 break;
581 }
582 }
583 end:;
586 if (translations.size() > 1) {
587 // If guessPlurals is not false here, plural form discard messages
588 // will be spewn out later.
589 msg.setPlural(true);
590 } else if (guessPlurals) {
591 // This might cause false positives, so it is a fallback only.
592 if (sourcetext.contains(strProN))
593 msg.setPlural(true);
594 }
595 msg.setTranslations(translations);
596 translations.clear();
597 msg.setContext(context);
598 msg.setSourceText(sourcetext);
599 msg.setComment(comment);
600 translator.append(msg);
601 }
602 if (utf8Fail) {
603 cd.appendError("Error: File contains invalid UTF-8 sequences."_L1);
604 return false;
605 }
606 return ok;
607}
608
609
610
611static bool containsStripped(const Translator &translator, const TranslatorMessage &msg)
612{
613 for (const TranslatorMessage &tmsg : translator.messages())
614 if (tmsg.sourceText() == msg.sourceText()
615 && tmsg.context() == msg.context()
616 && tmsg.comment().isEmpty())
617 return true;
618 return false;
619}
620
621bool saveQM(const Translator &translator, QIODevice &dev, ConversionData &cd)
622{
623 Releaser releaser(translator.languageCode());
624 QLocale::Language l;
625 QLocale::Territory c;
626 Translator::languageAndTerritory(translator.languageCode(), &l, &c);
627 QByteArray rules;
628 if (getNumerusInfo(l, c, &rules, 0, 0))
629 releaser.setNumerusRules(rules);
630
631 int finished = 0;
632 int unfinished = 0;
633 int untranslated = 0;
634 int droppedData = 0;
635
636 for (int i = 0; i != translator.messageCount(); ++i) {
637 const TranslatorMessage &msg = translator.message(i);
641 if (msg.translation().isEmpty() && msg.id().isEmpty()
642 && cd.m_unTrPrefix.isEmpty()) {
643 ++untranslated;
644 continue;
645 } else {
647 continue;
648 ++unfinished;
649 }
650 } else {
651 ++finished;
652 }
653 QStringList tlns = msg.translations();
655 && (!msg.id().isEmpty() || !cd.m_unTrPrefix.isEmpty()))
656 for (int j = 0; j < tlns.size(); ++j)
657 if (tlns.at(j).isEmpty())
658 tlns[j] = cd.m_unTrPrefix + msg.sourceText();
659 if (!msg.id().isEmpty()) {
660 if (!msg.context().isEmpty() || !msg.comment().isEmpty())
661 ++droppedData;
662 releaser.insertIdBased(msg, tlns);
663 } else {
664 // Drop the comment in (context, sourceText, comment),
665 // unless the context is empty,
666 // unless (context, sourceText, "") already exists or
667 // unless we already dropped the comment of (context,
668 // sourceText, comment0).
669 bool forceComment =
670 msg.comment().isEmpty()
671 || msg.context().isEmpty()
672 || containsStripped(translator, msg);
673 releaser.insert(msg, tlns, forceComment);
674 }
675 }
676 }
677
678 if (droppedData)
679 cd.appendError(QCoreApplication::translate("LRelease",
680 "Excess context/disambiguation dropped from %n message(s).", 0,
681 droppedData));
682
683 releaser.setDependencies(translator.dependencies());
684 releaser.squeeze(cd.m_saveMode);
685 bool saved = releaser.save(&dev);
686 if (saved && cd.isVerbose()) {
687 int generatedCount = finished + unfinished;
688 cd.appendError(QCoreApplication::translate("LRelease",
689 " Generated %n translation(s) (%1 finished and %2 unfinished)", 0,
690 generatedCount).arg(finished).arg(unfinished));
691 if (untranslated)
692 cd.appendError(QCoreApplication::translate("LRelease",
693 " Ignored %n untranslated source text(s)", 0,
694 untranslated));
695 }
696 return saved;
697}
698
700{
701 Translator::FileFormat format;
702
703 format.extension = "qm"_L1;
704 format.untranslatedDescription = QT_TRANSLATE_NOOP("FMT", "Compiled Qt translations");
706 format.priority = 0;
707 format.loader = &loadQM;
708 format.saver = &saveQM;
710
711 return 1;
712}
713
714Q_CONSTRUCTOR_FUNCTION(initQM)
715
716QT_END_NAMESPACE
bool operator<(const ByteTranslatorMessage &m) const
Definition qm.cpp:101
const QByteArray & sourceText() const
Definition qm.cpp:87
ByteTranslatorMessage(const QByteArray &context, const QByteArray &sourceText, const QByteArray &comment, const QStringList &translations)
Definition qm.cpp:76
const QByteArray & context() const
Definition qm.cpp:86
const QStringList & translations() const
Definition qm.cpp:89
const QByteArray & comment() const
Definition qm.cpp:88
bool isVerbose() const
Definition translator.h:32
TranslatorSaveMode m_saveMode
Definition translator.h:62
bool ignoreUnfinished() const
Definition translator.h:33
void insertIdBased(const TranslatorMessage &message, const QStringList &tlns)
Definition qm.cpp:404
Releaser(const QString &language)
Definition qm.cpp:133
bool save(QIODevice *iod)
Definition qm.cpp:225
void setDependencies(const QStringList &dependencies)
Definition qm.cpp:415
void squeeze(TranslatorSaveMode mode)
Definition qm.cpp:264
@ Hashes
Definition qm.cpp:131
@ Messages
Definition qm.cpp:131
@ Language
Definition qm.cpp:131
@ Dependencies
Definition qm.cpp:131
@ NumerusRules
Definition qm.cpp:131
@ Contexts
Definition qm.cpp:131
void setNumerusRules(const QByteArray &rules)
Definition qm.cpp:410
void insert(const TranslatorMessage &msg, const QStringList &tlns, bool forceComment)
Definition qm.cpp:387
void setPlural(bool isplural)
const TranslatorMessage & message(int i) const
Definition translator.h:141
static void registerFileFormat(const FileFormat &format)
void append(const TranslatorMessage &msg)
int messageCount() const
Definition translator.h:139
Combined button and popup list for selecting options.
static const int MagicLength
Definition qm.cpp:23
static quint32 read32(const uchar *data)
Definition qm.cpp:425
static bool containsStripped(const Translator &translator, const TranslatorMessage &msg)
Definition qm.cpp:611
bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd)
Definition qm.cpp:437
static void fromBytes(const char *str, int len, QString *out, bool *utf8Fail)
Definition qm.cpp:430
Q_DECLARE_TYPEINFO(ByteTranslatorMessage, Q_RELOCATABLE_TYPE)
static uint elfHash(const QByteArray &ba)
Definition qm.cpp:54
static quint8 read8(const uchar *data)
Definition qm.cpp:420
int initQM()
Definition qm.cpp:699
static const uchar magic[MagicLength]
Definition qm.cpp:24
Offset(uint hash, uint offset)
Definition qm.cpp:117
bool operator==(const Offset &other) const
Definition qm.cpp:124
bool operator<(const Offset &other) const
Definition qm.cpp:121
const char * untranslatedDescription
Definition translator.h:166
bool saveQM(const Translator &translator, QIODevice &dev, ConversionData &cd)
Definition qm.cpp:621
TranslatorSaveMode
@ SaveStripped
@ SaveEverything