4#ifndef TRANSLATORMESSAGE_H
5#define TRANSLATORMESSAGE_H
14enum TranslatorSaveMode { SaveEverything, SaveStripped };
28 {
return fileName() == other.fileName() && lineNumber() == other.lineNumber(); }
36 const QString &comment,
const QString &userData,
37 const QString &fileName,
int lineNumber,
38 const QStringList &translations = QStringList(),
44 void setId(
const QString &id) { m_id = id; }
47 void setContext(
const QString &context) { m_context = context; }
50 void setSourceText(
const QString &sourcetext) { m_sourcetext = sourcetext; }
52 void setOldSourceText(
const QString &oldsourcetext) { m_oldsourcetext = oldsourcetext; }
55 void setComment(
const QString &comment) { m_comment = comment; }
57 void setOldComment(
const QString &oldcomment) { m_oldcomment = oldcomment; }
60 void setTranslations(
const QStringList &translations) { m_translations = translations; }
62 void setTranslation(
const QString &translation) { m_translations = QStringList(translation); }
66 for (
const QString &trans : m_translations)
73 void setFileName(
const QString &fileName) { m_fileName = fileName; }
80 void addReference(
const QString &fileName,
int lineNumber);
86 void setUserData(
const QString &userData) { m_userData = userData; }
88 void setExtraComment(
const QString &extraComment) { m_extraComment = extraComment; }
92 void setWarning(
const QString &warning) {m_warning = warning;}
95 bool isNull()
const {
return m_sourcetext.isNull() && m_lineNumber == -1 && m_translations.isEmpty(); }
105 void setExtra(
const QString &ba,
const QString &var);
106 bool hasExtra(
const QString &ba)
const;
119 QString m_sourcetext;
120 QString m_oldsourcetext;
122 QString m_oldcomment;
125 QString m_extraComment;
126 QString m_translatorComment;
128 QStringList m_translations;
131 int m_tsLineNumber = -1;
133 bool m_warningOnly =
false;
int main(int argc, char *argv[])
[2]
bool sortContexts() const
QVector< QRegularExpression > m_excludes
const QDir & targetDir() const
const QStringList & dropTags() const
QSet< QString > m_projectRoots
TranslatorSaveMode m_saveMode
QMultiHash< QString, QString > m_allCSources
QStringList errors() const
bool ignoreUnfinished() const
void appendError(const QString &error)
QStringList m_includePath
QString m_compilationDatabaseDir
bool operator==(const TMMKey &o) const
TMMKey(const TranslatorMessage &msg)
bool operator==(const Reference &other) const
Reference(const QString &n, int l)
void setTranslations(const QStringList &translations)
void setTranslation(const QString &translation)
void setSourceText(const QString &sourcetext)
QList< Reference > References
void addReference(const QString &fileName, int lineNumber)
QString extraComment() const
TranslatorMessage(const QString &context, const QString &sourceText, const QString &comment, const QString &userData, const QString &fileName, int lineNumber, const QStringList &translations=QStringList(), Type type=Unfinished, bool plural=false)
void setContext(const QString &context)
References extraReferences() const
bool isTranslated() const
void setWarningOnly(bool isWarningOnly)
void setOldSourceText(const QString &oldsourcetext)
void setFileName(const QString &fileName)
QString translatorComment() const
void addReference(const Reference &ref)
void setId(const QString &id)
void setPlural(bool isplural)
void setUserData(const QString &userData)
void addReferenceUniq(const QString &fileName, int lineNumber)
void setTsLineNumber(int lineNumber)
QString sourceText() const
void setWarning(const QString &warning)
References allReferences() const
void setTranslatorComment(const QString &translatorComment)
QStringList translations() const
void setOldComment(const QString &oldcomment)
QString translation() const
void appendTranslation(const QString &translation)
void setReferences(const References &refs)
QHash< QString, QString > ExtraData
QString extra(const QString &ba) const
void setExtra(const QString &ba, const QString &var)
void setExtras(const ExtraData &extras)
void unsetExtra(const QString &key)
QString oldComment() const
void setLineNumber(int lineNumber)
const ExtraData & extras() const
QString oldSourceText() const
bool hasExtra(const QString &ba) const
void setComment(const QString &comment)
void setExtraComment(const QString &extraComment)
void setDependencies(const QStringList &dependencies)
bool(*) LoadFunction(Translator &, QIODevice &in, ConversionData &data)
static QString makeLanguageCode(QLocale::Language language, QLocale::Territory territory)
void stripObsoleteMessages()
QStringList normalizedTranslations(const TranslatorMessage &m, ConversionData &cd, bool *ok) const
bool save(const QString &filename, ConversionData &err, const QString &format) const
bool load(const QString &filename, ConversionData &err, const QString &format)
static QStringList normalizedTranslations(const TranslatorMessage &m, int numPlurals)
void stripEmptyContexts()
void stripUntranslatedMessages()
void stripFinishedMessages()
void replaceSorted(const TranslatorMessage &msg)
static void languageAndTerritory(QStringView languageCode, QLocale::Language *langPtr, QLocale::Territory *territoryPtr)
void stripNonPluralForms()
void setExtra(const QString &ba, const QString &var)
LocationsType locationsType() const
void setExtras(const ExtraData &extras)
bool(*) SaveFunction(const Translator &, QIODevice &out, ConversionData &data)
const TranslatorMessage & message(int i) const
int find(const QString &context) const
QString extra(const QString &ba) const
QString languageCode() const
static void registerFileFormat(const FileFormat &format)
void append(const TranslatorMessage &msg)
static constexpr QChar TextVariantSeparator
static QString guessLanguageCodeFromFileName(const QString &fileName)
void setLocationsType(LocationsType lt)
void stripIdenticalSourceTranslations()
static QList< FileFormat > & registeredFileFormats()
void makeFileNamesAbsolute(const QDir &originalPath)
QStringList dependencies() const
bool translationsExist() const
void setLanguageCode(const QString &languageCode)
const TranslatorMessage & constMessage(int i) const
Duplicates resolveDuplicates()
bool hasExtra(const QString &ba) const
void setSourceLanguageCode(const QString &languageCode)
int find(const QString &context, const QString &comment, const TranslatorMessage::References &refs) const
void normalizeTranslations(ConversionData &cd)
TranslatorMessage & message(int i)
void appendSorted(const TranslatorMessage &msg)
void reportDuplicatesLines(const TranslatorMessage &msg, const DuplicateEntries::value_type &dups) const
int find(const TranslatorMessage &msg) const
void reportDuplicates(const Duplicates &dupes, const QString &fileName, bool verbose)
const ExtraData & extras() const
const QList< TranslatorMessage > & messages() const
void extend(const TranslatorMessage &msg, ConversionData &cd)
QString sourceLanguageCode() const
static constexpr QChar BinaryVariantSeparator
Combined button and popup list for selecting options.
static QT_USE_NAMESPACE int usage(const QStringList &args)
DuplicateEntries byContents
size_t qHash(const TMMKey &key)
bool saveQM(const Translator &translator, QIODevice &dev, ConversionData &cd)
QString getNumerusInfoString()
Q_DECLARE_TYPEINFO(TMMKey, Q_RELOCATABLE_TYPE)
bool getNumerusInfo(QLocale::Language language, QLocale::Territory territory, QByteArray *rules, QStringList *forms, const char **gettextRules)
Q_DECLARE_TYPEINFO(TranslatorMessage, Q_RELOCATABLE_TYPE)