Version: 9.12.0
QtxTranslator Class Reference

Extended version of QTranslator. More...

#include <QtxTranslator.h>

Inheritance diagram for QtxTranslator:
Inheritance graph

Public Member Functions

 QtxTranslator (QObject *parent=0)
 Constructor. More...
 
 ~QtxTranslator ()
 Destructor. More...
 
virtual QString translate (const char *, const char *, const char *=0, int=-1) const
 Returns the translation for the key. More...
 

Detailed Description

Extended version of QTranslator.

In addition to the functionality provided by QTranslator class, QtxTranslator allows translating resources defined in the global context (i.e. common resources). The QtxTranslator can be used to workaround QTranslator's limitation which does not allow to process messages with global context.

For the current moment global context should be specified in translation (*.ts) files as "@default" string. For example:

<!DOCTYPE TS><TS>
<context>
  <name>@default</name>
  <message>
      <source>MY_MESSAGE</source>
      <translation>My translated message</translation>
  </message>
</context>
</TS>

Constructor & Destructor Documentation

◆ QtxTranslator()

QtxTranslator::QtxTranslator ( QObject parent = 0)

Constructor.

◆ ~QtxTranslator()

QtxTranslator::~QtxTranslator ( )

Destructor.

Member Function Documentation

◆ translate()

QString QtxTranslator::translate ( const char *  context,
const char *  sourceText,
const char *  disambiguation = 0,
int  n = -1 
) const
virtual

Returns the translation for the key.

Parameters
contextmessage context
sourceTextmessage source name
disambiguationmessage comment (optional)
noptional numeral to choose the appropriate form of translation
Returns
Translated text if found or sourceText otherwise

References GLOBAL_CONTEXT.


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