[GRASS-dev] Re: lib/gis/*.c: Extra calls to sprintf () just before G_warning ()

Ivan Shmakov oneingray at gmail.com
Mon Mar 23 10:10:14 EDT 2009


>>>>> Maris Nartiss <maris.gis at gmail.com> writes:

[...]

 >> * the code like the following could bring all the sorts of woe upon
 >> the heads of unsuspecting translators (this issue may deserve a
 >> mention on Trac.)

 >> --cut--
 >> 	    sprintf(buf,
 >> 		    _("Unable to read header file for raster map <%s@%s>."),
 >> 		    name, mapset);
 >> 	    tail = buf + strlen(buf);
 >> 	    sprintf(tail, _(" It is a reclass of raster map <%s@%s> "),
 >> 		    real_name, real_mapset);
 >> 	    tail = buf + strlen(buf);
 >> 	    if (!G_find_cell(real_name, real_mapset))
 >> 		sprintf(tail, _("which is missing."));
 >> 	    else
 >> 		sprintf(tail, _("whose header file can't be opened."));
 >> 	    G_warning ("%s", buf);
 >> 	    return -1;
 >> --cut--

 > Hello Ivan, It's good to see Your internationalisation efforts,

	It's more about cleaning the things up than i18n, actually.

 > still I spotted one huge NO-NO in Your patch - one should NEVER split
 > strings marked for translation.  Some languages may require opposite
 > word order in sentence or even different sentence for each case. Also
 > if translating such sentences is possible, it's hard, as it's not
 > possible to see whole sentence just it's start or end.

	Yes, that's why I've pointed the code fragment above, as it may
	easily be unsuitable for translation into some languages.
	Unfortunately, I have too little spare time nowadays to fix the
	issues like this myself, so I've just left the things untouched.

	Should I put the issue into Trac?

	... Or was your remark about the use of string literals'
	concatenation in my patch?  But, then, both the C compiler /and/
	gettext do support these properly.  Essentially, the C compiler
	isn't expected to treat, e. g., the following fragments
	differently:

   const char *hello = ("Hello, world!");

   const char *hello = ("He" "llo,"
                        " world!");	/* NB: same as "Hello, world!" */

	You may consider, e. g., the following change:

--- lib/gis/put_title.c	(revision 36445)
+++ lib/gis/put_title.c	(working copy)
@@ -25,10 +25,9 @@
     in = out = 0;
     in = G_fopen_old("cats", name, mapset);
     if (!in) {
-	sprintf(buf,
-		_("category information for [%s] in [%s] missing or invalid"),
-		name, mapset);
-	G_warning(buf);
+	G_warning (_("category information for [%s] in [%s]"
+		     " missing or invalid"),
+		   name, mapset);
 	return -1;
     }
 

	Despite the string appears ``split'', gettext still produces the
	correct result:

--cut: locale/templates/grasslibs.pot --
#: ../lib/gis/put_title.c:28
#, c-format
msgid "category information for [%s] in [%s] missing or invalid"
msgstr ""
--cut: locale/templates/grasslibs.pot --

[...]

-- 
FSF associate member #7257


More information about the grass-dev mailing list