From a8222d804d0905d04f294a7eebc00944a53dfe10 Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 11 Dec 2015 13:58:38 +0300 Subject: [PATCH] Add method to install custom translator to the application --- src/Qtx/QtxResourceMgr.cxx | 18 ++++++++++++++++++ src/Qtx/QtxResourceMgr.h | 1 + 2 files changed, 19 insertions(+) diff --git a/src/Qtx/QtxResourceMgr.cxx b/src/Qtx/QtxResourceMgr.cxx index cfb2f523a..35f052e03 100644 --- a/src/Qtx/QtxResourceMgr.cxx +++ b/src/Qtx/QtxResourceMgr.cxx @@ -2784,6 +2784,24 @@ void QtxResourceMgr::loadTranslator( const QString& prefix, const QString& name } } +/*! + \brief Add custom translator. + \param prefix parameter which defines translation context (for example, package name) + \param translator translator being installed + \sa loadLanguage(), loadTranslators() +*/ +void QtxResourceMgr::addTranslator( const QString& prefix, QTranslator* translator ) +{ + if ( translator ) + { + if ( !myTranslator[prefix].contains( translator ) ) { + myTranslator[prefix].append( translator ); + if ( QApplication::instance() ) + QApplication::instance()->installTranslator( translator ); + } + } +} + /*! \brief Remove all translators corresponding to the specified translation context. \param prefix parameter which defines translation context (for example, package name) diff --git a/src/Qtx/QtxResourceMgr.h b/src/Qtx/QtxResourceMgr.h index 3ffa49c03..2eb0d400e 100644 --- a/src/Qtx/QtxResourceMgr.h +++ b/src/Qtx/QtxResourceMgr.h @@ -157,6 +157,7 @@ public: void removeTranslators( const QString& ); void loadTranslator( const QString&, const QString& ); void loadTranslators( const QString&, const QStringList& ); + void addTranslator( const QString&, QTranslator* ); QString path( const QString&, const QString&, const QString& ) const; -- 2.39.2