[vlc-devel] [PATCH] Add possibility to translate Qt-native text via gettext
Mario Speiß
1034-135 at online.de
Sat Jan 5 22:21:15 CET 2013
This class makes all Qt-translations go through vlc gettext api (i.e. context
menu of QLineEdit can be translated now with vlc po-files)
Regards,
Mario
---
modules/gui/qt4/qt4.cpp | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index 11ae967..3e098a1
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -56,6 +56,22 @@
#endif
/*****************************************************************************
+ * Provide QTranslator-based translation of native Qt-API
+ * via gettext (and the .po-files)
+ *****************************************************************************/
+#include <QTranslator>
+
+class QVLCTranslator : public QTranslator
+{
+public:
+ virtual QString translate( const char *context, const char *sourceText,
+ const char *disambiguation = 0 ) const
+ {
+ return qtr( sourceText );
+ }
+};
+
+/*****************************************************************************
* Local prototypes.
*****************************************************************************/
static int OpenIntf ( vlc_object_t * );
@@ -460,6 +476,11 @@ static void *Thread( void *obj )
p_intf->p_sys->p_app = &app;
+ /* use VLC's gettext internationalization via .po-files also for native Qt-APIs
+ * (Example: QLineEdit context menu shows in English only) */
+ QVLCTranslator tor;
+ app.installTranslator( &tor );
+
/* All the settings are in the .conf/.ini style */
p_intf->p_sys->mainSettings = new QSettings(
#ifdef WIN32
--
1.7.5.4
More information about the vlc-devel
mailing list