Skip to content

Commit 711aa1e

Browse files
committed
browser: add i18n
(cherry picked from commit 35f3838)
1 parent 32414c5 commit 711aa1e

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

src/browser/main.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int main( int argc, char ** argv )
6868
gdalShares << QCoreApplication::applicationDirPath().append( "/share/gdal" )
6969
<< appResources.append( "/share/gdal" )
7070
<< appResources.append( "/gdal" );
71-
Q_FOREACH ( const QString& gdalShare, gdalShares )
71+
Q_FOREACH( const QString& gdalShare, gdalShares )
7272
{
7373
if ( QFile::exists( gdalShare ) )
7474
{
@@ -79,6 +79,39 @@ int main( int argc, char ** argv )
7979
}
8080
#endif
8181

82+
QString i18nPath = QgsApplication::i18nPath();
83+
bool myLocaleOverrideFlag = settings.value( "locale/overrideFlag", false ).toBool();
84+
QString myUserLocale = settings.value( "locale/userLocale", "" ).toString();
85+
QString myTranslationCode = !myLocaleOverrideFlag || myUserLocale.isEmpty() ? QLocale::system().name() : myUserLocale;
86+
87+
QTranslator qgistor( 0 );
88+
QTranslator qttor( 0 );
89+
if ( myTranslationCode != "C" )
90+
{
91+
if ( qgistor.load( QString( "qgis_" ) + myTranslationCode, i18nPath ) )
92+
{
93+
a.installTranslator( &qgistor );
94+
}
95+
else
96+
{
97+
qWarning( "loading of qgis translation failed [%s]", QString( "%1/qgis_%2" ).arg( i18nPath ).arg( myTranslationCode ).toLocal8Bit().constData() );
98+
}
99+
100+
/* Translation file for Qt.
101+
* The strings from the QMenuBar context section are used by Qt/Mac to shift
102+
* the About, Preferences and Quit items to the Mac Application menu.
103+
* These items must be translated identically in both qt_ and qgis_ files.
104+
*/
105+
if ( qttor.load( QString( "qt_" ) + myTranslationCode, QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ) )
106+
{
107+
a.installTranslator( &qttor );
108+
}
109+
else
110+
{
111+
qWarning( "loading of qt translation failed [%s]", QString( "%1/qt_%2" ).arg( QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ).arg( myTranslationCode ).toLocal8Bit().constData() );
112+
}
113+
}
114+
82115
QgsBrowser w;
83116

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

0 commit comments

Comments
 (0)