>>>>> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:

Jean-Marc> Updated patch attached. 

Argh!

JMarc

Index: src/frontends/qt4/GuiApplication.C
===================================================================
--- src/frontends/qt4/GuiApplication.C	(revision 17053)
+++ src/frontends/qt4/GuiApplication.C	(working copy)
@@ -30,6 +30,7 @@
 #include "Color.h"
 #include "debug.h"
 #include "funcrequest.h"
+#include "gettext.h"
 #include "lyx_main.h"
 #include "lyxfunc.h"
 #include "lyxrc.h"
@@ -113,9 +114,9 @@ GuiApplication::GuiApplication(int & arg
 	if (qt_trans_.load(language_name,
 		QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
 	{
-		qApp->installTranslator(&qt_trans_);
+		installTranslator(&qt_trans_);
 		// even if the language calls for RtL, don't do that
-		qApp->setLayoutDirection(Qt::LeftToRight);
+		setLayoutDirection(Qt::LeftToRight);
 		lyxerr[Debug::GUI]
 			<< "Successfully installed Qt translations for locale "
 			<< fromqstr(language_name) << std::endl;
@@ -124,6 +125,11 @@ GuiApplication::GuiApplication(int & arg
 			<< "Could not find  Qt translations for locale "
 			<< fromqstr(language_name) << std::endl;
 
+#ifdef Q_WS_MAC
+	// This allows to translate the strings that appear in the LyX menu.
+	addMenuTranslator();
+#endif
+
 	using namespace lyx::graphics;
 
 	Image::newImage = boost::bind(&QLImage::newImage);
@@ -305,6 +311,43 @@ bool GuiApplication::x11EventFilter(XEve
 #endif
 
 
+////////////////////////////////////////////////////////////////////////
+// Mac specific stuff goes here...
+#ifdef Q_WS_MACX
+
+class MenuTranslator : public QTranslator {
+	virtual ~MenuTranslator() {};
+	virtual QString translate(const char * context, 
+				  const char * sourceText, 
+				  const char * comment = 0) const;
+};
+
+
+QString MenuTranslator::translate(const char * context, 
+				  const char * sourceText, 
+				  const char *) const
+{
+	string const s = sourceText;
+	string const c = context;
+	if (c == "QMenuBar" 
+	    && (s == N_("About LyX")
+		|| s == N_("Preferences") || s == N_("Quit LyX")))
+		return toqstr(_(s));
+	else 
+		return QString();
+}
+
+
+void GuiApplication::addMenuTranslator()
+{
+	menu_trans_ = new MenuTranslator();
+	installTranslator(menu_trans_);
+}
+
+
+#endif
+
+
 } // namespace frontend
 } // namespace lyx
 
Index: src/frontends/qt4/GuiApplication.h
===================================================================
--- src/frontends/qt4/GuiApplication.h	(revision 17053)
+++ src/frontends/qt4/GuiApplication.h	(working copy)
@@ -32,6 +32,7 @@ class socket_callback;
 namespace frontend {
 
 class GuiWorkArea;
+class MenuTranslator;
 
 /// The Qt main application class
 /**
@@ -102,6 +103,12 @@ public:
 	bool x11EventFilter (XEvent * ev);
 #endif
 
+#ifdef Q_WS_MACX
+	/// A translator suitable for the entries in the LyX menu
+	void addMenuTranslator();
+	///
+	MenuTranslator * menu_trans_;
+#endif
 }; // GuiApplication
 
 extern GuiApplication * guiApp;

Reply via email to