From: vsr Date: Tue, 25 Oct 2016 12:05:06 +0000 (+0300) Subject: 0023375: [CEA] Add command line option to force application's language X-Git-Tag: V8_2_0a1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=39d2f7ca5cbf6b95641e861354799f67a7b0335d;p=modules%2Fgui.git 0023375: [CEA] Add command line option to force application's language --- diff --git a/src/Qtx/QtxResourceMgr.cxx b/src/Qtx/QtxResourceMgr.cxx index 4df9c1ff8..c5cd1d74e 100644 --- a/src/Qtx/QtxResourceMgr.cxx +++ b/src/Qtx/QtxResourceMgr.cxx @@ -2676,6 +2676,14 @@ QPixmap QtxResourceMgr::loadPixmap( const QString& prefix, const QString& name, return pix; } +/*! + \brief Specify default language for the application. +*/ +QString QtxResourceMgr::defaultLanguage() const +{ + return ""; +} + /*! \brief Load translation files according to the specified language. @@ -2707,6 +2715,8 @@ void QtxResourceMgr::loadLanguage( const QString& pref, const QString& l ) substMap.insert( 'A', appName() ); QString lang = l; + if ( lang.isEmpty() ) + lang = defaultLanguage(); if ( lang.isEmpty() ) value( langSection(), "language", lang ); diff --git a/src/Qtx/QtxResourceMgr.h b/src/Qtx/QtxResourceMgr.h index a7df2f268..6d9f28f8e 100644 --- a/src/Qtx/QtxResourceMgr.h +++ b/src/Qtx/QtxResourceMgr.h @@ -179,6 +179,8 @@ public: void refresh(); protected: + virtual QString defaultLanguage() const; + virtual void setDirList( const QStringList& ); virtual void setResource( const QString&, const QString&, const QString& ); diff --git a/src/SUIT/SUIT_ResourceMgr.cxx b/src/SUIT/SUIT_ResourceMgr.cxx index 92a64e7ab..0c98e4a2d 100755 --- a/src/SUIT/SUIT_ResourceMgr.cxx +++ b/src/SUIT/SUIT_ResourceMgr.cxx @@ -179,3 +179,21 @@ long SUIT_ResourceMgr::userFileId( const QString& ) const { return -1; } + +/*! + \brief Specify default language for the application. +*/ +QString SUIT_ResourceMgr::defaultLanguage() const +{ + QStringList arguments; + QString language; + if ( SUIT_Session::session() ) arguments = SUIT_Session::session()->arguments(); + // Try language, given in arguments + for (int i = 1; i < arguments.count(); i++) { + QRegExp rx ("--language=(.+)"); + if ( rx.indexIn( arguments[i] ) >= 0 && rx.captureCount() > 0 ) { + language = rx.cap(1); + } + } + return language; +} diff --git a/src/SUIT/SUIT_ResourceMgr.h b/src/SUIT/SUIT_ResourceMgr.h index 73c17c17c..8129aba07 100755 --- a/src/SUIT/SUIT_ResourceMgr.h +++ b/src/SUIT/SUIT_ResourceMgr.h @@ -42,6 +42,7 @@ protected: virtual QString userFileName( const QString&, const bool = true ) const; virtual QString findAppropriateUserFile( const QString& ) const; virtual long userFileId( const QString& ) const; + virtual QString defaultLanguage() const; private: QString myVersion;