diff --git a/development/MacOSX/Makefile.am b/development/MacOSX/Makefile.am index 895e12e9c6..9282d86a81 100644 --- a/development/MacOSX/Makefile.am +++ b/development/MacOSX/Makefile.am @@ -1,5 +1,7 @@ include $(top_srcdir)/config/common.am +LINGUAS = $(srcdir)/../../po/LINGUAS + SUBDIRS = spotlight bundledir = ${prefix}/Contents @@ -9,3 +11,9 @@ dist_bin_SCRIPTS = lyxeditor dist_pkgdata_DATA = COPYING LyXapp.icns LyX.icns lyxrc.dist + +install-data-hook: + LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" $(LINGUAS)`; \ + for f in $$LINGUAS_ ; do \ + $(MKDIR_P) $(pkgdatadir)/$$f.lproj ; \ + done diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 3d167ebce2..18da529ddc 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -31,6 +31,7 @@ #include "Color.h" #include "debug.h" #include "FuncRequest.h" +#include "gettext.h" #include "LyX.h" #include "LyXFunc.h" #include "LyXRC.h" @@ -119,9 +120,9 @@ GuiApplication::GuiApplication(int & argc, char ** argv) 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; @@ -130,6 +131,11 @@ GuiApplication::GuiApplication(int & argc, char ** argv) << "Could not find Qt translations for locale " << fromqstr(language_name) << std::endl; +#ifdef Q_WS_MACX + // This allows to translate the strings that appear in the LyX menu. + addMenuTranslator(); +#endif + using namespace lyx::graphics; Image::newImage = boost::bind(&QLImage::newImage); @@ -343,6 +349,38 @@ bool GuiApplication::x11EventFilter(XEvent * xev) #endif +//////////////////////////////////////////////////////////////////////// +// Mac specific stuff goes here... + +class MenuTranslator : public QTranslator { +public: + 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; + if (s == N_("About %1") || s == N_("Preferences") + || s == N_("Reconfigure") || s == N_("Quit %1")) + return qt_(s); + else + return QString(); +} + + +void GuiApplication::addMenuTranslator() +{ + menu_trans_.reset(new MenuTranslator()); + installTranslator(menu_trans_.get()); +} + + } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt4/GuiApplication.h b/src/frontends/qt4/GuiApplication.h index 10711794ec..ba0b4c2d72 100644 --- a/src/frontends/qt4/GuiApplication.h +++ b/src/frontends/qt4/GuiApplication.h @@ -21,6 +21,8 @@ #include "frontends/Application.h" +#include + #include #include @@ -32,6 +34,7 @@ class socket_callback; namespace frontend { class GuiWorkArea; +class MenuTranslator; /// The Qt main application class /** @@ -107,6 +110,11 @@ public: bool x11EventFilter (XEvent * ev); #endif + /// A translator suitable for the entries in the LyX menu. + /// Only needed with Qt/Mac. + void addMenuTranslator(); + /// + boost::scoped_ptr menu_trans_; }; // GuiApplication extern GuiApplication * guiApp;