Am Montag, 18. Oktober 2004 16:24 schrieb Jean-Marc Lasgouttes: > I really do not like the idea to use en.po whereas the user has set > for example LC_ALL=C. This really seems like a hack to me.
Ok, you convinced me. An additional advantage is that even if the translator does not know that he does not need to translate the context information but should leave it out, the correct message appears. I'll apply the attached version tomorrow. It even includes a tiny bit of documentation ;-) Georg
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/lib/doc/ChangeLog lyx-1.4-cvs/lib/doc/ChangeLog --- lyx-1.4-clean/lib/doc/ChangeLog 2004-10-18 21:43:18.000000000 +0200 +++ lyx-1.4-cvs/lib/doc/ChangeLog 2004-10-18 21:07:46.000000000 +0200 @@ -1,3 +1,8 @@ +2004-10-18 Georg Baum <[EMAIL PROTECTED]> + + * Customization.lyx: add description of translation of ambigous + messages + 2004-10-17 José Matos <[EMAIL PROTECTED]> * Depend.pl: removed. diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/lib/doc/Customization.lyx lyx-1.4-cvs/lib/doc/Customization.lyx --- lyx-1.4-clean/lib/doc/Customization.lyx 2004-10-11 14:05:31.000000000 +0200 +++ lyx-1.4-cvs/lib/doc/Customization.lyx 2004-10-18 21:03:29.000000000 +0200 @@ -2814,6 +2814,70 @@ README LYX-SOURCE-DIR/po/ \family default directory for more instructions. +\layout Subsubsection + +Ambigous messages +\layout Standard + +Sometimes it turns out that one english message needs to be translated into + different messages in the target language. + One example is the message +\family typewriter +To +\family default + which has the german translation +\family typewriter +Nach +\family default + or +\family typewriter +Bis +\family default +. + +\family typewriter +gettext +\family default + does not handle such ambigous translations. + Therefore you have to add some context information to the message: Instead + of +\family typewriter +To +\family default + it becomes +\family typewriter +To[[as in 'From format x to format y']] +\family default + and +\family typewriter +To[[as in 'From page x to page y']]. + +\family default + Now the two occurences of +\family typewriter +To +\family default + are different for +\family typewriter +gettext +\family default + and can be translated correctly to +\family typewriter +Nach +\family default + and +\family typewriter +Bis +\family default +, respectively. +\layout Standard + +Of course the context information needs to be stripped off the original + message when no translation is used. + Therefore you have to put it in double square brackets at the end of the + message (see the example above). + The translation mechanism of LyX ensures that everything in double square + brackets at the end of messages is removed before displaying the message. \layout Subsection Translating the documentation. @@ -2839,7 +2903,7 @@ As of February 2003, almost all of the d \emph on Tutorial \emph default - has been translated into at least 12 ther languages, with other translations + has been translated into at least 12 other languages, with other translations in progress. The library of translated documents is growing rapidly. \end_inset diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/po/ChangeLog lyx-1.4-cvs/po/ChangeLog --- lyx-1.4-clean/po/ChangeLog 2004-10-11 14:05:43.000000000 +0200 +++ lyx-1.4-cvs/po/ChangeLog 2004-10-18 20:24:10.000000000 +0200 @@ -1,3 +1,7 @@ +2004-10-18 Georg Baum <[EMAIL PROTECTED]> + + * de.po: update strings with context information + 2004-10-05 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * ru.po: fix crash when autosaving reported by Nikita V. diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/po/de.po lyx-1.4-cvs/po/de.po --- lyx-1.4-clean/po/de.po 2004-10-11 14:05:50.000000000 +0200 +++ lyx-1.4-cvs/po/de.po 2004-10-18 21:20:18.000000000 +0200 @@ -1538,8 +1538,7 @@ msgid "From:|#F" msgstr "Von:|#V" #: src/frontends/xforms/forms/form_preferences.fd:1960 -#: src/frontends/xforms/forms/form_print.fd:188 -msgid "To:|#T" +msgid "To:|#T[[as in 'From format x to format y']]" msgstr "Nach:|#N" #: src/frontends/xforms/forms/form_preferences.fd:1978 @@ -1726,6 +1725,10 @@ msgstr "Kopien" msgid "Sorted|#S" msgstr "Sortiert|#S" +#: src/frontends/xforms/forms/form_print.fd:188 +msgid "To:|#T[[as in 'From page x to page y']]" +msgstr "Bis:|#B" + #: src/frontends/xforms/forms/form_print.fd:224 msgid "Reverse order|#R" msgstr "Umgekehrte Reihenfolge|#R" @@ -3998,7 +4001,7 @@ msgid "C&onverter:" msgstr "&Konverter:" #: src/frontends/qt2/ui/QPrefConvertersModule.ui:220 -msgid "&To:" +msgid "&To:[[as in 'From format x to format y']]" msgstr "&Nach:" #: src/frontends/qt2/ui/QPrefConvertersModule.ui:235 @@ -4516,8 +4519,8 @@ msgid "Page number to print from" msgstr "Drucke ab Seite Nr." #: src/frontends/qt2/ui/QPrintDialogBase.ui:112 -msgid "&to" -msgstr "&bis" +msgid "&To:[[as in 'From page x to page y']]" +msgstr "&Bis:" #: src/frontends/qt2/ui/QPrintDialogBase.ui:131 msgid "Page number to print to" diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/frontends/qt2/ChangeLog lyx-1.4-cvs/src/frontends/qt2/ChangeLog --- lyx-1.4-clean/src/frontends/qt2/ChangeLog 2004-10-15 19:22:17.000000000 +0200 +++ lyx-1.4-cvs/src/frontends/qt2/ChangeLog 2004-10-18 20:34:22.000000000 +0200 @@ -1,3 +1,8 @@ +2004-10-18 Georg Baum <[EMAIL PROTECTED]> + + * ui/QPrefConvertersModule.ui: Add translation context to "To:" + * ui/QPrintDialogBase.ui: ditto + 2004-10-11 Andreas Vox <[EMAIL PROTECTED]> * qfont_loader.C (initFontPath, addToFontPath): two new static @@ -5,7 +10,7 @@ (available): remove special MacOSX code; use addToFontPath * lyx_gui.C (parse_init): add call to qfont_loader::initFontPath() - + 2004-10-01 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * QLPopupMenu.C (populate): move the code below to here, so that diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/frontends/qt2/ui/QPrefConvertersModule.ui lyx-1.4-cvs/src/frontends/qt2/ui/QPrefConvertersModule.ui --- lyx-1.4-clean/src/frontends/qt2/ui/QPrefConvertersModule.ui 2003-03-28 02:21:42.000000000 +0100 +++ lyx-1.4-cvs/src/frontends/qt2/ui/QPrefConvertersModule.ui 2004-10-18 20:35:04.000000000 +0200 @@ -217,7 +217,7 @@ </property> <property stdset="1"> <name>text</name> - <string>&To:</string> + <string>&To:[[as in 'From format x to format y']]</string> </property> <property> <name>buddy</name> diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/frontends/qt2/ui/QPrintDialogBase.ui lyx-1.4-cvs/src/frontends/qt2/ui/QPrintDialogBase.ui --- lyx-1.4-clean/src/frontends/qt2/ui/QPrintDialogBase.ui 2003-06-14 17:13:55.000000000 +0200 +++ lyx-1.4-cvs/src/frontends/qt2/ui/QPrintDialogBase.ui 2004-10-18 20:33:50.000000000 +0200 @@ -109,7 +109,7 @@ </property> <property stdset="1"> <name>text</name> - <string>&to</string> + <string>&To:[[as in 'From page x to page y']]</string> </property> <property> <name>buddy</name> diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/frontends/xforms/ChangeLog lyx-1.4-cvs/src/frontends/xforms/ChangeLog --- lyx-1.4-clean/src/frontends/xforms/ChangeLog 2004-10-11 14:06:55.000000000 +0200 +++ lyx-1.4-cvs/src/frontends/xforms/ChangeLog 2004-10-18 20:35:19.000000000 +0200 @@ -1,3 +1,8 @@ +2004-10-18 Georg Baum <[EMAIL PROTECTED]> + + * forms/form_preferences.fd: Add translation context to "To:" + * forms/form_print.fd: ditto + 2004-10-05 Angus Leeming <[EMAIL PROTECTED]> * FormPreferences.C: add code to input/output the indexing command. diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/frontends/xforms/forms/form_preferences.fd lyx-1.4-cvs/src/frontends/xforms/forms/form_preferences.fd --- lyx-1.4-clean/src/frontends/xforms/forms/form_preferences.fd 2004-10-11 14:06:59.000000000 +0200 +++ lyx-1.4-cvs/src/frontends/xforms/forms/form_preferences.fd 2004-10-18 20:35:58.000000000 +0200 @@ -1957,7 +1957,7 @@ alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_DEFAULT_SIZE lcol: FL_BLACK -label: To:|#T +label: To:|#T[[as in 'From format x to format y']] shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/frontends/xforms/forms/form_print.fd lyx-1.4-cvs/src/frontends/xforms/forms/form_print.fd --- lyx-1.4-clean/src/frontends/xforms/forms/form_print.fd 2004-03-28 16:12:33.000000000 +0200 +++ lyx-1.4-cvs/src/frontends/xforms/forms/form_print.fd 2004-10-18 20:35:33.000000000 +0200 @@ -185,7 +185,7 @@ alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: To:|#T +label: To:|#T[[as in 'From page x to page y']] shortcut: resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/ChangeLog lyx-1.4-cvs/src/ChangeLog --- lyx-1.4-clean/src/ChangeLog 2004-10-15 19:21:40.000000000 +0200 +++ lyx-1.4-cvs/src/ChangeLog 2004-10-17 18:21:35.000000000 +0200 @@ -1,3 +1,7 @@ +2004-10-18 Georg Baum <[EMAIL PROTECTED]> + + * messages.C (Pimpl): strip off translation context information + 2004-10-14 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * BufferView_pimpl.C (setBuffer): when closing a buffer, make sure diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/messages.C lyx-1.4-cvs/src/messages.C --- lyx-1.4-clean/src/messages.C 2004-06-09 18:53:41.000000000 +0200 +++ lyx-1.4-cvs/src/messages.C 2004-10-18 21:29:59.000000000 +0200 @@ -13,6 +13,8 @@ #include "support/filetools.h" #include "support/path_defines.h" +#include <boost/regex.hpp> + using lyx::support::GetEnvPath; using lyx::support::lyx_localedir; @@ -98,11 +100,24 @@ public: bindtextdomain(PACKAGE, lyx_localedir().c_str()); textdomain(PACKAGE); const char* msg = gettext(m.c_str()); - setlocale(LC_ALL, old); - free(old); + // Some english words have different translations, depending + // on context. In these cases the original string is + // augmented by context information (e.g. + // "To:[[as in 'From page x to page y']]" and + // "To:[[as in 'From format x to format y']]". + // This means that we need to filter out everything in + // double square brackets at the end of the string, + // otherwise the user sees bogus messages. // If we are unable to honour the request we just // return what we got in. - return (!n ? m : string(msg)); + string translated(n ? msg : m); + static boost::regex const reg("^([^\\[]*)\\[\\[[^\\]]*\\]\\]$"); + boost::smatch sub; + if (regex_match(translated, sub, reg)) + translated = sub.str(1); + setlocale(LC_ALL, old); + free(old); + return translated; } private: /// diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/messages.h lyx-1.4-cvs/src/messages.h --- lyx-1.4-clean/src/messages.h 2003-10-07 08:45:24.000000000 +0200 +++ lyx-1.4-cvs/src/messages.h 2004-09-07 09:01:34.000000000 +0200 @@ -17,9 +17,9 @@ /// class Messages { public: - /// + /// messages in the language defined by the environment Messages(); - /// + /// messages in the language \p l Messages(std::string const & l); /// ~Messages();