Skip to content

Commit c6b05b9

Browse files
committed
sourcelanguage instead of targetlanguage
it generates a general ts file instead of a file per targetlanguage
1 parent 3334b86 commit c6b05b9

4 files changed

+16
-5
lines changed

src/app/qgsprojectproperties.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -2218,4 +2218,10 @@ void QgsProjectProperties::onGenerateTsFileButton() const
22182218
{
22192219
QString l = cbtsLocale->currentData().toString();
22202220
QgsProject::instance()->generateTsFile( l );
2221+
QMessageBox::information( nullptr, tr( "General TS file generated" ), tr( "TS file generated with source language %1.\n"
2222+
"- open it with Qt Linguist\n"
2223+
"- translate strings\n"
2224+
"- save it with the postfix of the target language (eg. de)\n"
2225+
"- release to get qm file including postfix (eg. aproject_de.qm)\n"
2226+
"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 ) ) ;
22212227
}

src/core/qgsproject.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2820,7 +2820,7 @@ void QgsProject::generateTsFile( const QString &locale )
28202820
{
28212821
QgsTranslationContext translationContext;
28222822
translationContext.setProject( this );
2823-
translationContext.setFileName( QStringLiteral( "%1/%2_%3.ts" ).arg( absolutePath(), baseName(), locale ) );
2823+
translationContext.setFileName( QStringLiteral( "%1/%2.ts" ).arg( absolutePath(), baseName() ) );
28242824

28252825
emit QgsApplication::instance()->collectTranslatableObjects( &translationContext );
28262826

src/core/qgstranslationcontext.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,11 @@ void QgsTranslationContext::registerTranslation( const QString &context, const Q
5252

5353
void QgsTranslationContext::writeTsFile( const QString &locale )
5454
{
55-
QgsSettings settings;
56-
5755
//write xml
5856
QDomDocument doc( QStringLiteral( "TS" ) );
5957

6058
QDomElement tsElement = doc.createElement( QStringLiteral( "TS" ) );
61-
tsElement.setAttribute( QStringLiteral( "language" ), locale );
62-
tsElement.setAttribute( QStringLiteral( "sourcelanguage" ), settings.value( QStringLiteral( "locale/userLocale" ), "" ).toString() );
59+
tsElement.setAttribute( QStringLiteral( "sourcelanguage" ), locale );
6360
doc.appendChild( tsElement );
6461

6562
for ( const TranslatableObject &translatableObject : mTranslatableObjects )

src/ui/qgsprojectpropertiesbase.ui

+8
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,13 @@
806806
<string>Generate Project Translation File</string>
807807
</property>
808808
<layout class="QHBoxLayout" name="horizontalLayout_4">
809+
<item>
810+
<widget class="QLabel" name="sourceLanguageLabel">
811+
<property name="text">
812+
<string>Source language</string>
813+
</property>
814+
</widget>
815+
</item>
809816
<item>
810817
<widget class="QComboBox" name="cbtsLocale"/>
811818
</item>
@@ -2950,6 +2957,7 @@
29502957
<include location="../../images/images.qrc"/>
29512958
<include location="../../images/images.qrc"/>
29522959
<include location="../../images/images.qrc"/>
2960+
<include location="../../images/images.qrc"/>
29532961
</resources>
29542962
<connections>
29552963
<connection>

0 commit comments

Comments
 (0)