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
Translator Class Reference

#include <translator.h>

+ Collaboration diagram for Translator:

Classes

struct  Duplicates
 
struct  FileFormat
 

Public Types

enum  LocationsType { DefaultLocations , NoLocations , RelativeLocations , AbsoluteLocations }
 
enum  { TextVariantSeparator = 0x2762 , BinaryVariantSeparator = 0x9c }
 
using DuplicateEntries = QHash<int, QVector<int>>
 
typedef TranslatorMessage::ExtraData ExtraData
 
typedef bool(*) SaveFunction(const Translator &, QIODevice &out, ConversionData &data)
 
typedef bool(*) LoadFunction(Translator &, QIODevice &in, ConversionData &data)
 

Public Member Functions

 Translator ()
 
bool load (const QString &filename, ConversionData &err, const QString &format)
 
bool save (const QString &filename, ConversionData &err, const QString &format) const
 
int find (const TranslatorMessage &msg) const
 
int find (const QString &context, const QString &comment, const TranslatorMessage::References &refs) const
 
int find (const QString &context) const
 
void replaceSorted (const TranslatorMessage &msg)
 
void extend (const TranslatorMessage &msg, ConversionData &cd)
 
void append (const TranslatorMessage &msg)
 
void appendSorted (const TranslatorMessage &msg)
 
void stripObsoleteMessages ()
 
void stripFinishedMessages ()
 
void stripUntranslatedMessages ()
 
void stripEmptyContexts ()
 
void stripNonPluralForms ()
 
void stripIdenticalSourceTranslations ()
 
void dropTranslations ()
 
void dropUiLines ()
 
void makeFileNamesAbsolute (const QDir &originalPath)
 
bool translationsExist () const
 
Duplicates resolveDuplicates ()
 
void reportDuplicates (const Duplicates &dupes, const QString &fileName, bool verbose)
 
void reportDuplicatesLines (const TranslatorMessage &msg, const DuplicateEntries::value_type &dups) const
 
QString languageCode () const
 
QString sourceLanguageCode () const
 
void setLocationsType (LocationsType lt)
 
LocationsType locationsType () const
 
void setLanguageCode (const QString &languageCode)
 
void setSourceLanguageCode (const QString &languageCode)
 
const QList< TranslatorMessage > & messages () const
 
void normalizeTranslations (ConversionData &cd)
 
QStringList normalizedTranslations (const TranslatorMessage &m, ConversionData &cd, bool *ok) const
 
int messageCount () const
 
TranslatorMessagemessage (int i)
 
const TranslatorMessagemessage (int i) const
 
const TranslatorMessageconstMessage (int i) const
 
void dump () const
 
void setDependencies (const QStringList &dependencies)
 
QStringList dependencies () const
 
QString extra (const QString &ba) const
 
void setExtra (const QString &ba, const QString &var)
 
bool hasExtra (const QString &ba) const
 
const ExtraDataextras () const
 
void setExtras (const ExtraData &extras)
 

Static Public Member Functions

static QString makeLanguageCode (QLocale::Language language, QLocale::Territory territory)
 
static void languageAndTerritory (QStringView languageCode, QLocale::Language *langPtr, QLocale::Territory *territoryPtr)
 
static QString guessLanguageCodeFromFileName (const QString &fileName)
 
static QStringList normalizedTranslations (const TranslatorMessage &m, int numPlurals)
 
static void registerFileFormat (const FileFormat &format)
 
static QList< FileFormat > & registeredFileFormats ()
 

Detailed Description

Definition at line 88 of file translator.h.

Member Typedef Documentation

◆ DuplicateEntries

Definition at line 118 of file translator.h.

◆ ExtraData

◆ LoadFunction

bool(*) Translator::LoadFunction(Translator &, QIODevice &in, ConversionData &data)

Definition at line 167 of file translator.h.

◆ SaveFunction

bool(*) Translator::SaveFunction(const Translator &, QIODevice &out, ConversionData &data)

Definition at line 166 of file translator.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
TextVariantSeparator 
BinaryVariantSeparator 

Definition at line 182 of file translator.h.

◆ LocationsType

Enumerator
DefaultLocations 
NoLocations 
RelativeLocations 
AbsoluteLocations 

Definition at line 131 of file translator.h.

Constructor & Destructor Documentation

◆ Translator()

QT_BEGIN_NAMESPACE Translator::Translator ( )

Definition at line 28 of file translator.cpp.

Member Function Documentation

◆ append()

void Translator::append ( const TranslatorMessage & msg)

Definition at line 165 of file translator.cpp.

Referenced by appendSorted(), extend(), loadPO(), loadQM(), QPHReader::read(), TSReader::read(), and DataModel::release().

+ Here is the caller graph for this function:

◆ appendSorted()

void Translator::appendSorted ( const TranslatorMessage & msg)

Definition at line 170 of file translator.cpp.

References append(), and TranslatorMessage::lineNumber().

Referenced by replaceSorted().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ constMessage()

const TranslatorMessage & Translator::constMessage ( int i) const
inline

Definition at line 149 of file translator.h.

Referenced by updateTsFiles().

+ Here is the caller graph for this function:

◆ dependencies()

QStringList Translator::dependencies ( ) const
inline

Definition at line 153 of file translator.h.

◆ dropTranslations()

void Translator::dropTranslations ( )

Definition at line 468 of file translator.cpp.

Referenced by main(), and savePOT().

+ Here is the caller graph for this function:

◆ dropUiLines()

void Translator::dropUiLines ( )

Definition at line 477 of file translator.cpp.

Referenced by main().

+ Here is the caller graph for this function:

◆ dump()

void Translator::dump ( ) const

Definition at line 760 of file translator.cpp.

References TranslatorMessage::dump(), message(), and messageCount().

+ Here is the call graph for this function:

◆ extend()

void Translator::extend ( const TranslatorMessage & msg,
ConversionData & cd )

Definition at line 112 of file translator.cpp.

References append(), TranslatorMessage::extras(), find(), TranslatorMessage::lineNumber(), and TranslatorMessage::setExtras().

Referenced by FindTrCalls::endVisit(), and recordMessage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extra()

QString Translator::extra ( const QString & ba) const

Definition at line 750 of file translator.cpp.

◆ extras()

const ExtraData & Translator::extras ( ) const
inline

Definition at line 162 of file translator.h.

Referenced by DataModel::load(), savePO(), saveTS(), and saveXLIFF().

+ Here is the caller graph for this function:

◆ find() [1/3]

int Translator::find ( const QString & context) const

Definition at line 391 of file translator.cpp.

◆ find() [2/3]

int Translator::find ( const QString & context,
const QString & comment,
const TranslatorMessage::References & refs ) const

Definition at line 373 of file translator.cpp.

◆ find() [3/3]

int Translator::find ( const TranslatorMessage & msg) const

Definition at line 360 of file translator.cpp.

Referenced by extend(), and replaceSorted().

+ Here is the caller graph for this function:

◆ guessLanguageCodeFromFileName()

QString Translator::guessLanguageCodeFromFileName ( const QString & fileName)
static

Definition at line 719 of file translator.cpp.

◆ hasExtra()

bool Translator::hasExtra ( const QString & ba) const

Definition at line 745 of file translator.cpp.

◆ languageAndTerritory()

void Translator::languageAndTerritory ( QStringView languageCode,
QLocale::Language * langPtr,
QLocale::Territory * territoryPtr )
static

Definition at line 336 of file translator.cpp.

◆ languageCode()

QString Translator::languageCode ( ) const
inline

Definition at line 128 of file translator.h.

◆ load()

bool Translator::load ( const QString & filename,
ConversionData & err,
const QString & format )

Definition at line 244 of file translator.cpp.

◆ locationsType()

LocationsType Translator::locationsType ( ) const
inline

Definition at line 133 of file translator.h.

Referenced by DataModel::load(), and merge().

+ Here is the caller graph for this function:

◆ makeFileNamesAbsolute()

void Translator::makeFileNamesAbsolute ( const QDir & originalPath)

Definition at line 649 of file translator.cpp.

◆ makeLanguageCode()

QString Translator::makeLanguageCode ( QLocale::Language language,
QLocale::Territory territory )
static

Definition at line 326 of file translator.cpp.

◆ message() [1/2]

TranslatorMessage & Translator::message ( int i)
inline

Definition at line 147 of file translator.h.

Referenced by PRESUBMIT_test_mocks.MockOutputApi.PresubmitResult::__repr__(), applySameTextHeuristic(), and main().

+ Here is the caller graph for this function:

◆ message() [2/2]

const TranslatorMessage & Translator::message ( int i) const
inline

Definition at line 148 of file translator.h.

Referenced by PRESUBMIT_test_mocks.MockOutputApi.PresubmitResult::__repr__(), dump(), TranslatorMessagePtrBase::operator->(), and saveQM().

+ Here is the caller graph for this function:

◆ messageCount()

int Translator::messageCount ( ) const
inline

Definition at line 146 of file translator.h.

Referenced by applySameTextHeuristic(), dump(), DataModel::load(), main(), TSReader::read(), CppParser::recordResults(), saveQM(), and updateTsFiles().

+ Here is the caller graph for this function:

◆ messages()

const QList< TranslatorMessage > & Translator::messages ( ) const

Definition at line 664 of file translator.cpp.

◆ normalizedTranslations() [1/2]

QStringList Translator::normalizedTranslations ( const TranslatorMessage & m,
ConversionData & cd,
bool * ok ) const

◆ normalizedTranslations() [2/2]

QStringList Translator::normalizedTranslations ( const TranslatorMessage & m,
int numPlurals )
static

Definition at line 669 of file translator.cpp.

References TranslatorMessage::isPlural().

+ Here is the call graph for this function:

◆ normalizeTranslations()

void Translator::normalizeTranslations ( ConversionData & cd)

Definition at line 686 of file translator.cpp.

References TranslatorMessage::isPlural().

Referenced by main(), and releaseTranslator().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ registeredFileFormats()

QList< Translator::FileFormat > & Translator::registeredFileFormats ( )
static

Definition at line 46 of file translator.cpp.

◆ registerFileFormat()

void Translator::registerFileFormat ( const FileFormat & format)
static

Definition at line 34 of file translator.cpp.

References Translator::FileFormat::priority.

Referenced by initPO(), initQM(), initQPH(), initTS(), and initXLIFF().

+ Here is the caller graph for this function:

◆ replaceSorted()

void Translator::replaceSorted ( const TranslatorMessage & msg)

Definition at line 87 of file translator.cpp.

References appendSorted(), and find().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reportDuplicates()

void Translator::reportDuplicates ( const Duplicates & dupes,
const QString & fileName,
bool verbose )

Definition at line 609 of file translator.cpp.

◆ reportDuplicatesLines()

void Translator::reportDuplicatesLines ( const TranslatorMessage & msg,
const DuplicateEntries::value_type & dups ) const

Definition at line 636 of file translator.cpp.

References TranslatorMessage::tsLineNumber().

+ Here is the call graph for this function:

◆ resolveDuplicates()

Translator::Duplicates Translator::resolveDuplicates ( )

Definition at line 559 of file translator.cpp.

References TranslatorMessage::isTranslated(), and TranslatorMessage::tsLineNumber().

Referenced by DataModel::load(), main(), and releaseTranslator().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

bool Translator::save ( const QString & filename,
ConversionData & err,
const QString & format ) const

Definition at line 287 of file translator.cpp.

◆ setDependencies()

void Translator::setDependencies ( const QStringList & dependencies)
inline

Definition at line 152 of file translator.h.

◆ setExtra()

void Translator::setExtra ( const QString & ba,
const QString & var )

Definition at line 755 of file translator.cpp.

◆ setExtras()

void Translator::setExtras ( const ExtraData & extras)
inline

Definition at line 163 of file translator.h.

◆ setLanguageCode()

void Translator::setLanguageCode ( const QString & languageCode)
inline

Definition at line 138 of file translator.h.

◆ setLocationsType()

void Translator::setLocationsType ( LocationsType lt)
inline

Definition at line 132 of file translator.h.

Referenced by loadQPH(), main(), merge(), and TSReader::read().

+ Here is the caller graph for this function:

◆ setSourceLanguageCode()

void Translator::setSourceLanguageCode ( const QString & languageCode)
inline

Definition at line 139 of file translator.h.

◆ sourceLanguageCode()

QString Translator::sourceLanguageCode ( ) const
inline

Definition at line 129 of file translator.h.

◆ stripEmptyContexts()

void Translator::stripEmptyContexts ( )

Definition at line 436 of file translator.cpp.

◆ stripFinishedMessages()

void Translator::stripFinishedMessages ( )

Definition at line 407 of file translator.cpp.

References TranslatorMessage::Finished.

Referenced by main().

+ Here is the caller graph for this function:

◆ stripIdenticalSourceTranslations()

void Translator::stripIdenticalSourceTranslations ( )

Definition at line 456 of file translator.cpp.

Referenced by releaseTranslator().

+ Here is the caller graph for this function:

◆ stripNonPluralForms()

void Translator::stripNonPluralForms ( )

Definition at line 446 of file translator.cpp.

Referenced by main().

+ Here is the caller graph for this function:

◆ stripObsoleteMessages()

void Translator::stripObsoleteMessages ( )

Definition at line 397 of file translator.cpp.

References TranslatorMessage::Obsolete, and TranslatorMessage::Vanished.

Referenced by main().

+ Here is the caller graph for this function:

◆ stripUntranslatedMessages()

void Translator::stripUntranslatedMessages ( )

Definition at line 417 of file translator.cpp.

Referenced by main().

+ Here is the caller graph for this function:

◆ translationsExist()

bool Translator::translationsExist ( ) const

Definition at line 427 of file translator.cpp.


The documentation for this class was generated from the following files: