Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
sourcelanguage instead of targetlanguage
it generates a general ts file instead of a file per targetlanguage
Loading branch information
@@ -2218,4 +2218,10 @@ void QgsProjectProperties::onGenerateTsFileButton() const
{
QString l = cbtsLocale->currentData ().toString ();
QgsProject::instance ()->generateTsFile ( l );
QMessageBox::information ( nullptr , tr ( " General TS file generated" ), tr ( " TS file generated with source language %1.\n "
" - open it with Qt Linguist\n "
" - translate strings\n "
" - save it with the postfix of the target language (eg. de)\n "
" - release to get qm file including postfix (eg. aproject_de.qm)\n "
" When you open it again in QGIS having set the target language (de), the project will be translated and saved with postfix (eg. aproject_de.qgs)." ).arg ( l ) ) ;
}
@@ -2820,7 +2820,7 @@ void QgsProject::generateTsFile( const QString &locale )
{
QgsTranslationContext translationContext;
translationContext.setProject ( this );
translationContext.setFileName ( QStringLiteral ( " %1/%2_%3 .ts" ).arg ( absolutePath (), baseName (), locale ) );
translationContext.setFileName ( QStringLiteral ( " %1/%2 .ts" ).arg ( absolutePath (), baseName () ) );
emit QgsApplication::instance ()->collectTranslatableObjects ( &translationContext );
@@ -52,14 +52,11 @@ void QgsTranslationContext::registerTranslation( const QString &context, const Q
void QgsTranslationContext::writeTsFile ( const QString &locale )
{
QgsSettings settings;
// write xml
QDomDocument doc ( QStringLiteral ( " TS" ) );
QDomElement tsElement = doc.createElement ( QStringLiteral ( " TS" ) );
tsElement.setAttribute ( QStringLiteral ( " language" ), locale );
tsElement.setAttribute ( QStringLiteral ( " sourcelanguage" ), settings.value ( QStringLiteral ( " locale/userLocale" ), " " ).toString () );
tsElement.setAttribute ( QStringLiteral ( " sourcelanguage" ), locale );
doc.appendChild ( tsElement );
for ( const TranslatableObject &translatableObject : mTranslatableObjects )
@@ -806,6 +806,13 @@
<string >Generate Project Translation File</string >
</property >
<layout class =" QHBoxLayout" name =" horizontalLayout_4" >
<item >
<widget class =" QLabel" name =" sourceLanguageLabel" >
<property name =" text" >
<string >Source language</string >
</property >
</widget >
</item >
<item >
<widget class =" QComboBox" name =" cbtsLocale" />
</item >
@@ -2950,6 +2957,7 @@
<include location =" ../../images/images.qrc" />
<include location =" ../../images/images.qrc" />
<include location =" ../../images/images.qrc" />
<include location =" ../../images/images.qrc" />
</resources >
<connections >
<connection >
Toggle all file notes