4#ifndef METATRANSLATOR_H
5#define METATRANSLATOR_H
10#include <QCoreApplication>
15#include <QRegularExpression>
45 void appendError(
const QString &error) { m_errors.append(error); }
46 QString error()
const {
return m_errors.isEmpty() ? QString() : m_errors.join(QLatin1Char(
'\n')) + QLatin1Char(
'\n'); }
77 { context = msg.context(); source = msg.sourceText(); comment = msg.comment(); }
79 {
return context == o.context && source == o.source && comment == o.comment; }
85 return qHash(key.context) ^ qHash(key.source) ^ qHash(key.comment);
97 int find(
const QString &context,
100 int find(
const QString &context)
const;
126 const DuplicateEntries::value_type &dups)
const;
137 QLocale::Territory *territoryPtr);
152 void setDependencies(
const QStringList &dependencies) { m_dependencies = dependencies; }
160 void setExtra(
const QString &ba,
const QString &var);
161 bool hasExtra(
const QString &ba)
const;
162 const ExtraData &
extras()
const {
return m_extra; }
163 void setExtras(
const ExtraData &extras) { m_extra = extras; }
188 void delIndex(
int idx)
const;
189 void ensureIndexed()
const;
191 typedef QList<TranslatorMessage> TMM;
206 QString m_sourceLanguage;
207 QStringList m_dependencies;
210 mutable bool m_indexOk;
211 mutable QHash<QString,
int> m_ctxCmtIdx;
212 mutable QHash<QString,
int> m_idMsgIdx;
213 mutable QHash<TMMKey,
int> m_msgIdx;
216bool getNumerusInfo(QLocale::Language language, QLocale::Territory territory, QByteArray *rules,
217 QStringList *forms,
const char **gettextRules);
224
225
226
227#define ContextComment "QT_LINGUIST_INTERNAL_CONTEXT_COMMENT"
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)
QList< Reference > References
QHash< QString, QString > ExtraData
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)