Re: [LyX/master] More QDialogButtonBox
Am Mittwoch, den 18.07.2018, 00:44 +0200 schrieb Jean-Marc Lasgouttes: > Le 10/07/2018 à 12:53, Jürgen Spitzmüller a écrit : > > Am Dienstag, den 10.07.2018, 11:24 +0200 schrieb Jean-Marc > > Lasgouttes: > > > A solution would be to create our own QTranslator child that does > > > the > > > translation using the po files and falls back to Qt otherwise. I > > > can > > > give it a go next week. > > > > I would prefer the other way round: try Qt and provide a fallback > > solution if necessary. The translations of strings for "Apply", > > "Reset" > > etc. differ between OSes/DEs, and LyX should adapt to the context > > here. > > Does Qt really change its own translations? In which case? Actually, I am not sure it does. But at least having Qt translations as default assures consistency with other Qt apps. Jürgen > > Anyway, here is a patch. If you want to se the missing translations, > use > "-dbg locale". You will found that there are many strings passed > there, > and I do not know why they are used. > > I have not updated all po files for now. Kornel, could you try it > out > and check that this is what you need? You will have to add words to > translate to GuiApplication.cpp. > > JMarc signature.asc Description: This is a digitally signed message part
Re: [LyX/master] More QDialogButtonBox
Am Donnerstag, den 19.07.2018, 18:49 +0200 schrieb Stephan Witt: > I tried both and cannot see a difference. So the removal is my > favorite. > Can anybody give a hint, please? Yes, removal is correct. I overlooked this since it is not active here. Jürgen > > Patch attached. > > Regards, > Stephan > signature.asc Description: This is a digitally signed message part
Re: [LyX/master] More QDialogButtonBox
Am 10.07.2018 um 09:06 schrieb Juergen Spitzmueller : > > commit b5c5083c6c035294e8a762bd5bd737a56d27317a > Author: Juergen Spitzmueller > Date: Tue Jul 10 09:04:42 2018 +0200 > >More QDialogButtonBox > >Listings through Prefs. > > src/frontends/qt4/GuiDialog.cpp |1 + > src/frontends/qt4/GuiListings.cpp | 11 +- > src/frontends/qt4/GuiLog.cpp|3 +- > src/frontends/qt4/GuiMathMatrix.cpp | 18 +- > src/frontends/qt4/GuiMathMatrix.h |1 + > src/frontends/qt4/GuiNote.cpp |8 +- > src/frontends/qt4/GuiParagraph.cpp | 56 ++-- > src/frontends/qt4/GuiParagraph.h|8 +- > src/frontends/qt4/GuiPhantom.cpp|8 +- > src/frontends/qt4/GuiPrefs.cpp | 14 +- > src/frontends/qt4/InsetParamsDialog.cpp | 87 -- > src/frontends/qt4/InsetParamsDialog.h | 13 +- > src/frontends/qt4/ui/InsetParamsUi.ui | 142 +++--- > src/frontends/qt4/ui/ListingsUi.ui | 457 ++- > src/frontends/qt4/ui/LogUi.ui | 239 > src/frontends/qt4/ui/MathMatrixUi.ui| 75 ++--- > src/frontends/qt4/ui/NoteUi.ui | 93 +++ > src/frontends/qt4/ui/ParagraphUi.ui | 253 +++-- > src/frontends/qt4/ui/PhantomUi.ui | 97 +++ > src/frontends/qt4/ui/PrefsUi.ui | 130 ++--- > 20 files changed, 749 insertions(+), 965 deletions(-) This change broke the build on Mac. The offending code is at line 70 of GuiParagraph.cpp and is enclosed by an ifdef. I’m not sure if the failing code should be removed or adapted like the code in on_synchronizedViewCB_toggled() method. I tried both and cannot see a difference. So the removal is my favorite. Can anybody give a hint, please? Patch attached. Regards, Stephan amend-b5c5083c6c035294e8a762bd5bd737a56d27317a.patch Description: Binary data
Re: [LyX/master] More QDialogButtonBox
Am Mittwoch, 18. Juli 2018 07:44:39 CEST schrieb Jean-Marc Lasgouttes : > Le 18 juillet 2018 02:19:22 GMT+02:00, Kornel Benko a écrit : > >Works. That is very nice. I started with the most often used > > "&Ok", "Apply" and "Reset" > >used for instance at paragraph-settings. > > > > Kornel > > Very good. Can I let you take over from now and commit once you are confident > that all needed translations are in? > > JMarc > Will do :) . Please commit your sent patch. Kornel signature.asc Description: This is a digitally signed message part.
Re: [LyX/master] More QDialogButtonBox
Le 18 juillet 2018 02:19:22 GMT+02:00, Kornel Benko a écrit : >Works. That is very nice. I started with the most often used > "&Ok", "Apply" and "Reset" >used for instance at paragraph-settings. > > Kornel Very good. Can I let you take over from now and commit once you are confident that all needed translations are in? JMarc
Re: [LyX/master] More QDialogButtonBox
Am Mittwoch, 18. Juli 2018 00:45:17 CEST schrieb Jean-Marc Lasgouttes : > Le 18/07/2018 à 00:44, Jean-Marc Lasgouttes a écrit : > > Le 10/07/2018 à 12:53, Jürgen Spitzmüller a écrit : > >> Am Dienstag, den 10.07.2018, 11:24 +0200 schrieb Jean-Marc Lasgouttes: > >>> A solution would be to create our own QTranslator child that does > >>> the > >>> translation using the po files and falls back to Qt otherwise. I can > >>> give it a go next week. > >> > >> I would prefer the other way round: try Qt and provide a fallback > >> solution if necessary. The translations of strings for "Apply", "Reset" > >> etc. differ between OSes/DEs, and LyX should adapt to the context here. > > > > Does Qt really change its own translations? In which case? > > > > Anyway, here is a patch. If you want to se the missing translations, use > > "-dbg locale". You will found that there are many strings passed there, > > and I do not know why they are used. I don't know either, but that the only important are the ones which appear if using some dialogs. > > I have not updated all po files for now. Please don't do it, it should be sufficient to add them in GuiApplication.cpp > > Kornel, could you try it out > > and check that this is what you need? You will have to add words to > > translate to GuiApplication.cpp. > > > > JMarc > > Grmf. Works. That is very nice. I started with the most often used "&Ok", "Apply" and "Reset" used for instance at paragraph-settings. Kornel signature.asc Description: This is a digitally signed message part.
Re: [LyX/master] More QDialogButtonBox
Le 18/07/2018 à 00:44, Jean-Marc Lasgouttes a écrit : Le 10/07/2018 à 12:53, Jürgen Spitzmüller a écrit : Am Dienstag, den 10.07.2018, 11:24 +0200 schrieb Jean-Marc Lasgouttes: A solution would be to create our own QTranslator child that does the translation using the po files and falls back to Qt otherwise. I can give it a go next week. I would prefer the other way round: try Qt and provide a fallback solution if necessary. The translations of strings for "Apply", "Reset" etc. differ between OSes/DEs, and LyX should adapt to the context here. Does Qt really change its own translations? In which case? Anyway, here is a patch. If you want to se the missing translations, use "-dbg locale". You will found that there are many strings passed there, and I do not know why they are used. I have not updated all po files for now. Kornel, could you try it out and check that this is what you need? You will have to add words to translate to GuiApplication.cpp. JMarc Grmf. >From cbc2d9ec500141162332b8ef9692a9babb3e44e9 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 18 Jul 2018 00:41:09 +0200 Subject: [PATCH] Add a translator as a fallback to Qt inner one This reuses code intended only for mac manus and generalizes it. The list of strings to add to po files is found in GuiTranslator::translate. This is useful now that LyX relies on QDialogButtonBox class for its dialogs. Indeed many languages are not covered natively by Qt. It is possible to enable the "locace" debug channel to see what strings are not covered and should be added to our own translation tables. In order to make things easier, a new method getIfFound() has been added to the Messages class, which returns an empty string when no translation has been found, as Qt's translate() does. --- src/frontends/qt4/GuiApplication.cpp | 49 src/support/Messages.cpp | 13 src/support/Messages.h | 5 ++- 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 25eff65ec2..e04c392474 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -664,16 +664,10 @@ public: }; - -// -// Mac specific stuff goes here... -// - - -class MenuTranslator : public QTranslator +class GuiTranslator : public QTranslator { public: - MenuTranslator(QObject * parent) + GuiTranslator(QObject * parent = nullptr) : QTranslator(parent) {} @@ -687,15 +681,30 @@ public: const char * /*comment*/ = 0) const #endif { - 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(); +#if 0 + // Here we declare the strings that need to be translated from Qt own GUI + // This is needed to include these strings to po files + _("About %1"); + _("Preferences"); + _("Reconfigure"); + _("Quit %1")); +#endif + docstring s = getGuiMessages().getIfFound(sourceText); + // This test should eventually be removed when translations are updated + if (s.empty()) + LYXERR(Debug::LOCALE, "Missing translation for `" + << string(sourceText) << "'"); + return toqstr(s); } }; + + +// +// Mac specific stuff goes here... +// + + #ifdef Q_OS_MAC // QMacPasteboardMimeGraphics can only be compiled on Mac. @@ -944,8 +953,10 @@ struct GuiApplication::Private FontLoader font_loader_; /// ColorCache color_cache_; - /// + /// the built-in Qt translation mechanism QTranslator qt_trans_; + /// LyX gettext-based translation for Qt elements + GuiTranslator gui_trans_; /// QHash socket_notifiers_; /// @@ -1025,7 +1036,9 @@ GuiApplication::GuiApplication(int & argc, char ** argv) qsrand(QDateTime::currentDateTime().toTime_t()); - // Install translator for GUI elements. + // Install LyX translator for missing Qt translations + installTranslator(&d->gui_trans_); + // Install Qt native translator for GUI elements. installTranslator(&d->qt_trans_); #ifdef QPA_XCB @@ -1044,10 +1057,6 @@ GuiApplication::GuiApplication(int & argc, char ** argv) // FIXME: Do we need a lyxrc setting for this on Mac? This behaviour // seems to be the default case for applications like LyX. setQuitOnLastWindowClosed(false); - // This allows to translate the strings that appear in the LyX menu. - /// A translator suitable for the entries in the LyX menu. - /// Only needed with Qt/Mac. - installTranslator(new MenuTranslator(this)); /// setupApplescript(); #endif diff --git a/src/support/Messages.cpp b/src/support/Messages.cpp index 26a320b2d2..c87b6b976
Re: [LyX/master] More QDialogButtonBox
Le 10/07/2018 à 12:53, Jürgen Spitzmüller a écrit : Am Dienstag, den 10.07.2018, 11:24 +0200 schrieb Jean-Marc Lasgouttes: A solution would be to create our own QTranslator child that does the translation using the po files and falls back to Qt otherwise. I can give it a go next week. I would prefer the other way round: try Qt and provide a fallback solution if necessary. The translations of strings for "Apply", "Reset" etc. differ between OSes/DEs, and LyX should adapt to the context here. Does Qt really change its own translations? In which case? Anyway, here is a patch. If you want to se the missing translations, use "-dbg locale". You will found that there are many strings passed there, and I do not know why they are used. I have not updated all po files for now. Kornel, could you try it out and check that this is what you need? You will have to add words to translate to GuiApplication.cpp. JMarc
Re: [LyX/master] More QDialogButtonBox
Am Dienstag, 10. Juli 2018 13:50:30 CEST schrieb Jean-Marc Lasgouttes : > Le 10/07/2018 à 12:14, Kornel Benko a écrit : > > Am Dienstag, 10. Juli 2018 11:52:28 CEST schrieb Jean-Marc Lasgouttes > > : > >> Le 10/07/2018 à 11:34, Kornel Benko a écrit : > A solution would be to create our own QTranslator child that does the > translation using the po files and falls back to Qt otherwise. I can > give it a go next week. > > JMarc > >>> > >>> That would be nice :) > >> > >> Do we have a list of entries that we need? We already have some for the > >> Mac menus (so that the special code there could be removed). I propose > >> to create entries like "&OK[Qt]" or, if you prefer, without the [Qt] > >> context. > > > > I just checked: Apply Cancel Close Ok Reset > > I am sure there are other strings: at least there are the special menus > names on macOS. I searched in all .ui and .cpp files. But of course, QT _can_ use more. 'designer' shows: Ok, Save, SaveAll, Open, Yes, YesToAll, No, NoToAll, Abort, Retry, Ignore, Close, Cancel, Discard, Apply, Reset, RestoreDefaults > And shall I add a context? > > JMarc > Yes please, if possible. Kornel signature.asc Description: This is a digitally signed message part.
Re: [LyX/master] More QDialogButtonBox
Le 10/07/2018 à 12:14, Kornel Benko a écrit : Am Dienstag, 10. Juli 2018 11:52:28 CEST schrieb Jean-Marc Lasgouttes : Le 10/07/2018 à 11:34, Kornel Benko a écrit : A solution would be to create our own QTranslator child that does the translation using the po files and falls back to Qt otherwise. I can give it a go next week. JMarc That would be nice :) Do we have a list of entries that we need? We already have some for the Mac menus (so that the special code there could be removed). I propose to create entries like "&OK[Qt]" or, if you prefer, without the [Qt] context. I just checked: Apply Cancel Close Ok Reset I am sure there are other strings: at least there are the special menus names on macOS. And shall I add a context? JMarc
Re: [LyX/master] More QDialogButtonBox
Am Dienstag, den 10.07.2018, 11:24 +0200 schrieb Jean-Marc Lasgouttes: > A solution would be to create our own QTranslator child that does > the > translation using the po files and falls back to Qt otherwise. I can > give it a go next week. I would prefer the other way round: try Qt and provide a fallback solution if necessary. The translations of strings for "Apply", "Reset" etc. differ between OSes/DEs, and LyX should adapt to the context here. Jürgen > > JMarc signature.asc Description: This is a digitally signed message part
Re: [LyX/master] More QDialogButtonBox
Am Dienstag, 10. Juli 2018 11:52:28 CEST schrieb Jean-Marc Lasgouttes : > Le 10/07/2018 à 11:34, Kornel Benko a écrit : > >> A solution would be to create our own QTranslator child that does the > >> translation using the po files and falls back to Qt otherwise. I can > >> give it a go next week. > >> > >> JMarc > > > > That would be nice :) > > Do we have a list of entries that we need? We already have some for the > Mac menus (so that the special code there could be removed). I propose > to create entries like "&OK[Qt]" or, if you prefer, without the [Qt] > context. I just checked: Apply Cancel Close Ok Reset > JMarc Kornel signature.asc Description: This is a digitally signed message part.
Re: [LyX/master] More QDialogButtonBox
Le 10/07/2018 à 11:34, Kornel Benko a écrit : A solution would be to create our own QTranslator child that does the translation using the po files and falls back to Qt otherwise. I can give it a go next week. JMarc That would be nice :) Do we have a list of entries that we need? We already have some for the Mac menus (so that the special code there could be removed). I propose to create entries like "&OK[Qt]" or, if you prefer, without the [Qt] context. JMarc
Re: [LyX/master] More QDialogButtonBox
Le 10/07/2018 à 11:24, Jean-Marc Lasgouttes a écrit : In German GUI it looks OK, but unfortunately not in Slovak. Could not find the needed language package. A solution would be to create our own QTranslator child that does the translation using the po files and falls back to Qt otherwise. I can give it a go next week. I see we already have a MenuTranslator for macOS. I will have to study this. JMarc
Re: [LyX/master] More QDialogButtonBox
Am Dienstag, 10. Juli 2018 11:24:57 CEST schrieb Jean-Marc Lasgouttes : > Le 10/07/2018 à 11:04, Kornel Benko a écrit : > > Am Dienstag, 10. Juli 2018 10:38:00 CEST schrieb Jürgen Spitzmüller > > : > >> Am Dienstag, den 10.07.2018, 10:24 +0200 schrieb Kornel Benko: > >>> There is a small glitch in using QDialogButtonBox:: ... > >>> The translation is done with respect to the local language (e.g env > >>> LANG, LANGUAGE) > >>> and not with respect to then lyx-GUI language. > >>> > >>> For instance > >>> QDialogButtonBox::Cancel > >>> displays "Abbrechen" because my LANGUAGE environment is set to > >>> "de_DE". > >> > >> I suppose the same applies to file dialog, warning dialog and all other > >> native qt dialogs we use, right? > > > > Yes :( > > It might be possible to force Qt locale to the one we want. > > >>> Moreover, if QT does not have the correct translation, it uses the > >>> English version. > >> > >> But these are the most basic strings of any OS. > > > > In German GUI it looks OK, but unfortunately not in Slovak. > > Could not find the needed language package. > > A solution would be to create our own QTranslator child that does the > translation using the po files and falls back to Qt otherwise. I can > give it a go next week. > > JMarc That would be nice :) Kornel signature.asc Description: This is a digitally signed message part.
Re: [LyX/master] More QDialogButtonBox
Le 10/07/2018 à 11:04, Kornel Benko a écrit : Am Dienstag, 10. Juli 2018 10:38:00 CEST schrieb Jürgen Spitzmüller : Am Dienstag, den 10.07.2018, 10:24 +0200 schrieb Kornel Benko: There is a small glitch in using QDialogButtonBox:: ... The translation is done with respect to the local language (e.g env LANG, LANGUAGE) and not with respect to then lyx-GUI language. For instance QDialogButtonBox::Cancel displays "Abbrechen" because my LANGUAGE environment is set to "de_DE". I suppose the same applies to file dialog, warning dialog and all other native qt dialogs we use, right? Yes :( It might be possible to force Qt locale to the one we want. Moreover, if QT does not have the correct translation, it uses the English version. But these are the most basic strings of any OS. In German GUI it looks OK, but unfortunately not in Slovak. Could not find the needed language package. A solution would be to create our own QTranslator child that does the translation using the po files and falls back to Qt otherwise. I can give it a go next week. JMarc
Re: [LyX/master] More QDialogButtonBox
Am Dienstag, 10. Juli 2018 10:38:00 CEST schrieb Jürgen Spitzmüller : > Am Dienstag, den 10.07.2018, 10:24 +0200 schrieb Kornel Benko: > > There is a small glitch in using QDialogButtonBox:: ... > > The translation is done with respect to the local language (e.g env > > LANG, LANGUAGE) > > and not with respect to then lyx-GUI language. > > > > For instance > > QDialogButtonBox::Cancel > > displays "Abbrechen" because my LANGUAGE environment is set to > > "de_DE". > > I suppose the same applies to file dialog, warning dialog and all other > native qt dialogs we use, right? Yes :( > > Moreover, if QT does not have the correct translation, it uses the > > English version. > > But these are the most basic strings of any OS. In German GUI it looks OK, but unfortunately not in Slovak. Could not find the needed language package. > Jürgen Kornel signature.asc Description: This is a digitally signed message part.
Re: [LyX/master] More QDialogButtonBox
Am Dienstag, 10. Juli 2018 10:24:03 CEST schrieb Kornel Benko : > Am Dienstag, 10. Juli 2018 09:06:42 CEST schrieb Juergen Spitzmueller > : > > commit b5c5083c6c035294e8a762bd5bd737a56d27317a > > Author: Juergen Spitzmueller > > Date: Tue Jul 10 09:04:42 2018 +0200 > > > > More QDialogButtonBox > > > > Listings through Prefs. > > There is a small glitch in using QDialogButtonBox:: ... > The translation is done with respect to the local language (e.g env LANG, > LANGUAGE) > and not with respect to then lyx-GUI language. > > For instance > QDialogButtonBox::Cancel > displays "Abbrechen" because my LANGUAGE environment is set to "de_DE". Ahm, this is not correct. It was only the 'linguist'-po-editor display. > Moreover, if QT does not have the correct translation, it uses the English > version. But this is still valid. Kornel signature.asc Description: This is a digitally signed message part.
Re: [LyX/master] More QDialogButtonBox
Am Dienstag, den 10.07.2018, 10:24 +0200 schrieb Kornel Benko: > There is a small glitch in using QDialogButtonBox:: ... > The translation is done with respect to the local language (e.g env > LANG, LANGUAGE) > and not with respect to then lyx-GUI language. > > For instance > QDialogButtonBox::Cancel > displays "Abbrechen" because my LANGUAGE environment is set to > "de_DE". I suppose the same applies to file dialog, warning dialog and all other native qt dialogs we use, right? > Moreover, if QT does not have the correct translation, it uses the > English version. But these are the most basic strings of any OS. Jürgen > > Kornel > > signature.asc Description: This is a digitally signed message part
Re: [LyX/master] More QDialogButtonBox
Am Dienstag, 10. Juli 2018 09:06:42 CEST schrieb Juergen Spitzmueller : > commit b5c5083c6c035294e8a762bd5bd737a56d27317a > Author: Juergen Spitzmueller > Date: Tue Jul 10 09:04:42 2018 +0200 > > More QDialogButtonBox > > Listings through Prefs. There is a small glitch in using QDialogButtonBox:: ... The translation is done with respect to the local language (e.g env LANG, LANGUAGE) and not with respect to then lyx-GUI language. For instance QDialogButtonBox::Cancel displays "Abbrechen" because my LANGUAGE environment is set to "de_DE". Moreover, if QT does not have the correct translation, it uses the English version. Kornel signature.asc Description: This is a digitally signed message part.