Skip to content

Commit

Permalink
sourcelanguage instead of targetlanguage
Browse files Browse the repository at this point in the history
it generates a general ts file instead of a file per targetlanguage
  • Loading branch information
signedav committed Aug 22, 2018
1 parent 3334b86 commit c6b05b9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -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 ) ) ;
}
2 changes: 1 addition & 1 deletion src/core/qgsproject.cpp
Expand Up @@ -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 );

Expand Down
5 changes: 1 addition & 4 deletions src/core/qgstranslationcontext.cpp
Expand Up @@ -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 )
Expand Down
8 changes: 8 additions & 0 deletions src/ui/qgsprojectpropertiesbase.ui
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit c6b05b9

Please sign in to comment.