19 #include <QTextStream> 20 #include <QDomElement> 21 #include <QDomDocument> 47 TranslatableObject translatableObject;
48 translatableObject.context = context;
49 translatableObject.source = source;
50 mTranslatableObjects.append( translatableObject );
56 QDomDocument doc( QStringLiteral(
"TS" ) );
58 QDomElement tsElement = doc.createElement( QStringLiteral(
"TS" ) );
59 tsElement.setAttribute( QStringLiteral(
"sourcelanguage" ), locale );
60 doc.appendChild( tsElement );
62 for (
const TranslatableObject &translatableObject : mTranslatableObjects )
64 QDomElement contextElement = doc.createElement( QStringLiteral(
"context" ) );
65 tsElement.appendChild( contextElement );
67 QDomElement nameElement = doc.createElement( QStringLiteral(
"name" ) );
68 QDomText nameText = doc.createTextNode( translatableObject.context );
69 nameElement.appendChild( nameText );
70 contextElement.appendChild( nameElement );
72 QDomElement messageElement = doc.createElement( QStringLiteral(
"message" ) );
73 contextElement.appendChild( messageElement );
75 QDomElement sourceElement = doc.createElement( QStringLiteral(
"source" ) );
76 QDomText sourceText = doc.createTextNode( translatableObject.source );
77 sourceElement.appendChild( sourceText );
78 messageElement.appendChild( sourceElement );
80 QDomElement translationElement = doc.createElement( QStringLiteral(
"translation" ) );
81 translationElement.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"unfinished" ) );
82 messageElement.appendChild( translationElement );
87 tsFile.open( QIODevice::WriteOnly );
88 QTextStream stream( &tsFile );
89 stream << doc.toString();
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
QString fileName() const
Returns the TS fileName.
void writeTsFile(const QString &locale)
Writes the Ts-file.
void setFileName(const QString &fileName)
Sets the fileName of the TS file.
void registerTranslation(const QString &context, const QString &source)
Registers the source to be translated.
void setProject(QgsProject *project)
Sets the project being translated.
QgsProject * project() const
Returns the project.