Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
browser: add i18n
  • Loading branch information
jef-n committed Jun 19, 2015
1 parent 2125f6a commit 35f3838
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/browser/main.cpp
Expand Up @@ -69,7 +69,7 @@ int main( int argc, char ** argv )
gdalShares << QCoreApplication::applicationDirPath().append( "/share/gdal" )
<< appResources.append( "/share/gdal" )
<< appResources.append( "/gdal" );
Q_FOREACH ( const QString& gdalShare, gdalShares )
Q_FOREACH( const QString& gdalShare, gdalShares )
{
if ( QFile::exists( gdalShare ) )
{
Expand All @@ -80,6 +80,39 @@ int main( int argc, char ** argv )
}
#endif

QString i18nPath = QgsApplication::i18nPath();
bool myLocaleOverrideFlag = settings.value( "locale/overrideFlag", false ).toBool();
QString myUserLocale = settings.value( "locale/userLocale", "" ).toString();
QString myTranslationCode = !myLocaleOverrideFlag || myUserLocale.isEmpty() ? QLocale::system().name() : myUserLocale;

QTranslator qgistor( 0 );
QTranslator qttor( 0 );
if ( myTranslationCode != "C" )
{
if ( qgistor.load( QString( "qgis_" ) + myTranslationCode, i18nPath ) )
{
a.installTranslator( &qgistor );
}
else
{
qWarning( "loading of qgis translation failed [%s]", QString( "%1/qgis_%2" ).arg( i18nPath ).arg( myTranslationCode ).toLocal8Bit().constData() );
}

/* Translation file for Qt.
* The strings from the QMenuBar context section are used by Qt/Mac to shift
* the About, Preferences and Quit items to the Mac Application menu.
* These items must be translated identically in both qt_ and qgis_ files.
*/
if ( qttor.load( QString( "qt_" ) + myTranslationCode, QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ) )
{
a.installTranslator( &qttor );
}
else
{
qWarning( "loading of qt translation failed [%s]", QString( "%1/qt_%2" ).arg( QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ).arg( myTranslationCode ).toLocal8Bit().constData() );
}
}

QgsBrowser w;

a.connect( &a, SIGNAL( aboutToQuit() ), &w, SLOT( saveWindowState() ) );
Expand Down

0 comments on commit 35f3838

Please sign in to comment.