After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 113433 - Don't use markup in gnome-panel messages
Don't use markup in gnome-panel messages
Status: RESOLVED FIXED
Product: gnome-panel
Classification: Other
Component: general
2.3.x
Other All
: Normal normal
: ---
Assigned To: Panel Maintainers
Panel Maintainers
Depends on:
Blocks: 112527
 
 
Reported: 2003-05-21 10:10 UTC by Christian Rose
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: 2.3/2.4


Attachments
proposed fix for first noted instance (827 bytes, patch)
2003-06-08 00:11 UTC, Thomas Benson
none Details | Review
ignore the previous patch -- this one should fix both instances in launcher.c. (26.80 KB, patch)
2003-06-08 02:21 UTC, Thomas Benson
none Details | Review
Ugh, I attached the wrong file last time. Here is the real patch. (1.22 KB, patch)
2003-06-09 03:56 UTC, Thomas Benson
none Details | Review
patch for the 5 files mentioned above (9.52 KB, patch)
2003-06-09 18:35 UTC, Thomas Benson
none Details | Review
Patch for the two instances noted above in menu.c (1.09 KB, patch)
2003-06-11 03:13 UTC, Thomas Benson
none Details | Review
Well, here's a patch that does it with two strings if Mark decides that's how it should be done. It's ugly though. (1.74 KB, patch)
2003-06-12 03:56 UTC, Thomas Benson
none Details | Review
I'm a patch. Click me! ;) (48.25 KB, patch)
2003-06-17 09:56 UTC, Christian Neumair
none Details | Review
New gnome_panel_error implementation, arg3+4 form the format string, the rest is done by a va_list. This saves many lines + slight unrelated changes to function calls I needed to change anyway. (17.65 KB, patch)
2003-07-07 19:05 UTC, Christian Neumair
none Details | Review

Description Christian Rose 2003-05-21 10:10:05 UTC
#: gnome-panel/launcher.c:173
#, c-format
msgid ""
"<b>Cannot launch icon</b>\n"
"\n"
"Details: %s"

#: gnome-panel/launcher.c:1100 gnome-panel/menu.c:1230
#: gnome-panel/panel-util.c:81
#, c-format
msgid ""
"<b>Cannot display help document</b>\n"
"\n"
"Details: %s"

#: gnome-panel/menu.c:373
#, c-format
msgid ""
"<b>Can't execute 'About GNOME'</b>\n"
"\n"
"Details: %s probably does not exist"

#: gnome-panel/menu.c:397
#, c-format
msgid ""
"<b>Can't launch entry</b>\n"
"\n"
"Details: %s"

#: gnome-panel/menu.c:407 gnome-panel/menu.c:1204 gnome-panel/menu.c:1241
#, c-format
msgid ""
"<b>Can't load entry</b>\n"
"\n"
"Details: %s"

#: gnome-panel/menu.c:1108
#, c-format
msgid ""
"<b>Could not remove the menu item %s</b>\n"
"\n"
"Details: %s\n"

#: gnome-panel/menu.c:1195
msgid ""
"<b>Can't add to run box</b>\n"
"\n"
"Details: No 'Exec' or 'URL' field in entry"

#: gnome-panel/menu-ditem.c:123
#, c-format
msgid ""
"<b>Cannot save changes to launcher</b>\n"
"\n"
"Details: %s"

#. class
#: gnome-panel/menu-ditem.c:494
#, c-format
msgid ""
"<b>Cannot save menu item to disk</b>\n"
"\n"
"Details: %s"

#: gnome-panel/panel-run-dialog.c:276
#, c-format
msgid ""
"<b>Error launching command: '%s'</b>\n"
"\n"
"Details: %s"

#: gnome-panel/panel-run-dialog.c:305
#, c-format
msgid ""
"<b>Error displaying location: '%s'</b>\n"
"\n"
"Details: %s"

#: gnome-panel/panel-util.c:1440
msgid ""
"<b>Cannot execute xscreensaver</b>\n"
"\n"
"Details: xscreensaver-command not found"


Please DON'T use markup in messages like this. The rationale can be found
on the
http://developer.gnome.org/doc/tutorials/gnome-i18n/developer.html#avoid-markup
page.

Quote from mark@skynet.ie:

'As Christian explained elsewhere this is quite trivial to fix - e.g. the
last example:

#: gnome-panel/panel-util.c:1440
msgid ""
"<b>Cannot execute xscreensaver</b>\n"
"\n"
"Details: xscreensaver-command not found"

You'd change the code to something like this:


  msg = g_strdup_printf ("<b>%s</b>\n\n%s\n",
                    _("Cannot execute xscreensaver"),
                    _("Details: xscreensaver-command not found"));

  /* use msg */

  g_free (msg);

This way translators don't have to "translate" the markup. Marking the
bug as easy-fix - hopefully someone will take it on.'
Comment 1 Mark McLoughlin 2003-05-21 10:15:33 UTC
gnome-games ?  Had me confused here for a second  :-)
Comment 2 Christian Rose 2003-05-21 10:17:41 UTC
D'oh. Yeah, I'm confused. Thanks for fixing the subject.
Comment 3 Thomas Benson 2003-06-08 00:09:46 UTC
I am going to attach a patch with a proposed fix for the strings in
launcher.c.  If this is correct, I will create patches for the others
as well.
Comment 4 Thomas Benson 2003-06-08 00:11:26 UTC
Created attachment 17303 [details] [review]
proposed fix for first noted instance
Comment 5 Thomas Benson 2003-06-08 02:21:23 UTC
Created attachment 17305 [details] [review]
ignore the previous patch -- this one should fix both instances in launcher.c.
Comment 6 Thomas Benson 2003-06-09 03:56:38 UTC
Created attachment 17341 [details] [review]
Ugh, I attached the wrong file last time.  Here is the real patch.
Comment 7 Mark McLoughlin 2003-06-09 14:05:11 UTC
Couple of nitpicks:

1) Don't bother using gchar ... char is the same thing
2) Do

  char *msg;

  msg = g_str...

instead of

  char *msg = g_str..


Apart from that, it looks fine to commmit. Please go ahead. Thanks
much :-)
Comment 8 Thomas Benson 2003-06-09 18:29:49 UTC
I don't have CVS access (this is actually my first patch submission),
but I will attach a patch for all of the files (let me know if you'd
prefer a separate patch for each file).  I assume that whoever commits
the patches does the ChangeLog entry?
Comment 9 Thomas Benson 2003-06-09 18:35:03 UTC
Created attachment 17367 [details] [review]
patch for the 5 files mentioned above
Comment 10 Mark McLoughlin 2003-06-10 10:50:43 UTC
Thanks a million Thomas. I've committed your patch:

2003-06-10  Mark McLoughlin  <mark@skynet.ie>
                                                                     
                                         
        Re-order message construction throughout the panel so
        that Pango markup is not marked for translation. Patch
        from Thomas Benson <tbenson@cs.utk.edu> in #113433.
                                                                     
                                         
        * launcher.c: (launch_cb), (launcher_show_help):
        * menu-ditem.c: (ditem_properties_close),
        (really_add_new_menu_item):
        * menu.c: (about_gnome_cb), (activate_app_def), (remove_menuitem),
        (add_to_run_dialog), (show_help_on):
        * panel-run-dialog.c: (panel_run_dialog_launch_command),
        (panel_run_dialog_show_url):
        * panel-util.c: (panel_show_help), (panel_lock_screen):
        Don't translate pango markup.
                                                                     
                                         
Comment 11 Christian Rose 2003-06-10 23:32:03 UTC
Thanks Thomas for the patch. Unfortunately there's a problem in it
that I overlooked previously. It's this change:

 		esc = g_markup_escape_text (sim->item_loc, -1);
+		msg = g_strdup_printf ("<b>%s %s</b>\n\n%s: %s\n",
+			_("Could not remove the menu item"),
+			esc,
+			_("Details"),
+			gnome_vfs_result_to_string (result));
 
 		panel_error_dialog (
 			menuitem_to_screen (sim->menuitem),
 			"cant_remove_menu_item",
-			_("<b>Could not remove the menu item %s</b>\n\n"
-			  "Details: %s\n"), 
-			esc,
-			gnome_vfs_result_to_string (result));
+			msg);


Some languages may need to reorder the words in the sentence "Could
not remove the menu item %s" and so the %s might need to move around
when translated. Hence, the full sentence "Could not remove the menu
item %s" must be in a single message. I hope it's solvable without too
much added trouble...
Comment 12 Thomas Benson 2003-06-11 02:51:47 UTC
Oops, sorry about that.  Isn't this also a problem?

+		msg = g_strdup_printf ("<b>%s</b>\n\n%s: %s %s",
+			_("Can't execute 'About GNOME'"),
+			_("Details"), program_path,
+			_("probably does not exist"));

I'll attach a patch for those two.  Are the two panel-run-dialog.c
changes okay?
Comment 13 Thomas Benson 2003-06-11 03:13:51 UTC
Created attachment 17419 [details] [review]
Patch for the two instances noted above in menu.c
Comment 14 Mark McLoughlin 2003-06-11 10:28:56 UTC
Uggh, thanks guys.

So hmm, Thomas - you're patch isn't going to work AFAICT. printf
doesn't have recursive behaviour so the "%s probably doesn't exist"
bit won't have the %s substituted. So you'd actually need to do a
second printf ... at which point I think its getting too complicated
to actually be beneficial.

Christian: what do you think ?
Comment 15 Thomas Benson 2003-06-11 13:08:23 UTC
Oh yeah, you're right...I don't see any reasonable way to do it either
then.
Comment 16 Christian Rose 2003-06-11 22:10:38 UTC
To answer Thomas' first comment, yes, that second message also has the
same problem. That problem is more severe than having markup in the
message, so the current state is kind of worse than the original one.

I still believe this can be solved, with printf and a second string.

                detail_msg = g_strdup_printf (
                        _("%s probably does not exist"),
                        program_path);
		msg = g_strdup_printf ("<b>%s</b>\n\n%s %s",
			_("Can't execute 'About GNOME'"),
			_("Details:"), detail_msg);

Not pretty, but should work, I think. Can perhaps be made prettier and
more general with a seperate function for outputting this kind of
error messages.
Comment 17 Thomas Benson 2003-06-12 03:56:24 UTC
Created attachment 17475 [details] [review]
Well, here's a patch that does it with two strings if Mark decides that's how it should be done.  It's ugly though.
Comment 18 Mark McLoughlin 2003-06-12 10:40:49 UTC
Christian: I'm not saying it can't be solved ... I'm saying that this
seriously obfuscates the code and makes more use of the heap ...

At what point is it no longer worth the effort ? 
Comment 19 Christian Rose 2003-06-12 21:29:59 UTC
My personal opinion is that this is well within the limits of what's
reasonable to still do.

An important aspect of issues like this, that is easy to forget, is
that a "simple" solution tends to cause problems in other areas. One
needs to look at the big picture, and realize that the source is the
source for many translations as well, so there's a one-to-many mapping
with one line of potentially elegant and easily maintainable but
localization-wise troublesome source code causing trouble a multitude
of times, one for each and every translation that has to be created
and maintained. Remember that gnome-panel has 56 translations.
Seen that way, it can often be regarded as more efficient to fix the
problem in the source code rather than trying to work around it 56
times over. That's at least one interesting way of looking at it. 
Comment 20 Christian Neumair 2003-06-15 20:20:09 UTC
Sorry, I consider this way of solving the problems as bogus. I'll
submit a better patch at #112527.
Menthos: a printf ("%s %s", _("Details:"), detail_msg) solution is
totally inacceptable for RTL languages - you definitly need a way to
set the details output order. We ought to g_strconcat the first part
(like "<b>", _("firststring"), "</b>\n\n", _("Details: %s"), NULL) and
then insert the rest using printf (concattedstring, detail_msg).

regs,
 Chris
Comment 21 Christian Neumair 2003-06-17 09:56:04 UTC
Created attachment 17573 [details] [review]
I'm a patch. Click me! ;)
Comment 22 Christian Neumair 2003-06-18 11:01:19 UTC
Mark: Could you please review this patch?

regs,
 Chris
Comment 23 Christian Rose 2003-06-24 21:26:34 UTC
cneumair: Sorry, yes, overlooked that part.
Comment 24 Mark McLoughlin 2003-07-07 13:42:44 UTC
Christian: I hadn't seen this patch (no PATCH keyword) ... but the
same thing goes here as in #112527. I am not reviewing a patch that
has things like:

-	g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
+	g_warning (G_STRLOC ": GConf error : '%s'", our_error->message);

(If you want to go through all the panel's strings and do
s/gconf/GConf/, please do and send me the patch that you commit.
Personally, though I think this is just a waste of translators time to
have go and re-translate all the messages)

or 

- 
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
GTK_RESPONSE_REJECT);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+				 GTK_RESPONSE_REJECT);

I don't want random code formatting changes.


and I don't understand why you do this:

+	tmp_str = g_strconcat (_("Force this application to exit?"),
+			       "\n",
+			       _("(Any open documents will be lost.)"),
+			       NULL);
+
 	dialog = gtk_message_dialog_new (NULL, 0,
 					 GTK_MESSAGE_QUESTION,
 					 GTK_BUTTONS_NONE,
-					 _("Force this application to exit?\n"
-					   "(Any open documents will be lost.)"));
- 
+					 tmp_str);

What's wrong with using gtk_message_dialog like this ?

Oh, I see it now - you don't want to translate "\n". You do realise
this patch makes the panel use the heap *much* more ? I find it hard
to justify this runtime expense in my own mind ... please open a new
bug about this where we can discuss it.


But most importantly, you've just dumped a *huge* patch into this bug
when most of it has *nothing* to do with the bug ! :/



Comment 25 Christian Neumair 2003-07-07 19:05:59 UTC
Created attachment 18108 [details] [review]
New gnome_panel_error implementation, arg3+4 form the format string, the rest is done by a va_list. This saves many lines + slight unrelated changes to function calls I needed to change anyway.
Comment 26 Mark McLoughlin 2003-07-11 08:47:32 UTC
I'm a little bit unhappy that panel_error_dialog is a bit confusing to
use with this ... e.g.

+		panel_error_dialog (screen,
+				    "cannot_show_url_dialog",
+				    _("Cannot show %s"),
+				    error->message,
+				    url);
+

Here "url" looks like a coding error and error->message would actually
get substitued in for %s.

On the other hand, the hackiness is confined to panel_error_dialog and
it does clean up like a lot of stuff.

Please go ahead and commit to HEAD Manny. Great work, thanks :-)
Comment 27 Christian Neumair 2003-07-11 10:17:04 UTC
In fact we haven't got any possibility to avoid that - or does
[arg1,2]
format1,
va_list1,
format2,
va_list2

work, too?

regs,
 Chris
Comment 28 Mark McLoughlin 2003-07-11 11:38:04 UTC
No, that can't really be made to work I don't think. Its fine the way
you've done it. Please commit ...
Comment 29 Christian Neumair 2003-07-11 13:07:36 UTC
Done. Closing.

regs,
 Chris