Skip to content

Commit

Permalink
Also plug in translation for the short-lived dummy app when initiatin…
Browse files Browse the repository at this point in the history
…g the platform utilities
  • Loading branch information
nirvn committed Jul 26, 2024
1 parent 44a8881 commit ef469aa
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ int main( int argc, char **argv )
QCoreApplication::setApplicationName( qfield::appName );
const QSettings settings;
const QString customLanguage = settings.value( "/customLanguage", QString() ).toString();

#if WITH_SENTRY
const bool enableSentry = settings.value( "/enableInfoCollection", true ).toBool();
if ( enableSentry )
Expand All @@ -109,6 +110,23 @@ int main( int argc, char **argv )

Q_INIT_RESOURCE( qml );

QTranslator qfieldTranslator;
QTranslator qtTranslator;
bool qfieldTranslatorLoaded = false;
bool qtTranslatorLoaded = false;
if ( !customLanguage.isEmpty() )
{
qfieldTranslatorLoaded = qfieldTranslator.load( QStringLiteral( "qfield_%1" ).arg( customLanguage ), QStringLiteral( ":/i18n/" ), "_" );
qtTranslatorLoaded = qtTranslator.load( QStringLiteral( "qt_%1" ).arg( customLanguage ), QStringLiteral( ":/i18n/" ), "_" );
}
if ( !qfieldTranslatorLoaded || qfieldTranslator.isEmpty() )
( void ) qfieldTranslator.load( QLocale(), "qfield", "_", ":/i18n/" );
if ( !qtTranslatorLoaded || qtTranslator.isEmpty() )
( void ) qtTranslator.load( QLocale(), "qt", "_", ":/i18n/" );

dummyApp->installTranslator( &qtTranslator );
dummyApp->installTranslator( &qfieldTranslator );

QtWebView::initialize();

PlatformUtilities *platformUtils = PlatformUtilities::instance();
Expand Down Expand Up @@ -189,20 +207,6 @@ int main( int argc, char **argv )
QCoreApplication::setOrganizationDomain( "opengis.ch" );
QCoreApplication::setApplicationName( qfield::appName );

QTranslator qfieldTranslator;
QTranslator qtTranslator;
bool qfieldTranslatorLoaded = false;
bool qtTranslatorLoaded = false;
if ( !customLanguage.isEmpty() )
{
qfieldTranslatorLoaded = qfieldTranslator.load( QStringLiteral( "qfield_%1" ).arg( customLanguage ), QStringLiteral( ":/i18n/" ), "_" );
qtTranslatorLoaded = qtTranslator.load( QStringLiteral( "qt_%1" ).arg( customLanguage ), QStringLiteral( ":/i18n/" ), "_" );
}
if ( !qfieldTranslatorLoaded || qfieldTranslator.isEmpty() )
( void ) qfieldTranslator.load( QLocale(), "qfield", "_", ":/i18n/" );
if ( !qtTranslatorLoaded || qtTranslator.isEmpty() )
( void ) qtTranslator.load( QLocale(), "qt", "_", ":/i18n/" );

app.installTranslator( &qtTranslator );
app.installTranslator( &qfieldTranslator );

Expand Down

1 comment on commit ef469aa

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.