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 131505 - intltool should support translator comments in xml files
intltool should support translator comments in xml files
Status: RESOLVED FIXED
Product: intltool
Classification: Deprecated
Component: general
unspecified
Other All
: High normal
: ---
Assigned To: intltool maintainers
intltool maintainers
Depends on:
Blocks: 130998
 
 
Reported: 2004-01-15 00:44 UTC by Christian Rose
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Extract comments for translators for XML and .schemas files (2.73 KB, patch)
2004-04-05 18:16 UTC, Danilo Segan
accepted-commit_now Details | Review
Support for comments in XML files (with testcases) (9.42 KB, patch)
2004-05-06 16:33 UTC, Danilo Segan
none Details | Review

Description Christian Rose 2004-01-15 00:44:14 UTC
xgettext has a nice feature for automatically extracting comments, usually
aimed for translators, into the po files. Please see
http://developer.gnome.org/doc/tutorials/gnome-i18n/developer.html#use-comments.

This is sometimes essential for translators to be able to translate some
things correctly, and it is much needed also in other formats such as
schema files and XML files in general. Hence, intltool should probably be
capable of automatically extracting such comments out of XML files and
placing them as translator comments in the pot/po files.
Comment 1 Mark McLoughlin 2004-04-05 15:58:14 UTC
Yeah, we really need this. e.g. in GConf schemas you might have

  <locale name="C">
    <default>24-hour</default>
    ...
  </locale>

and you really, really want to be able to do:

  <locale name="C">
    <!-- 
      Translators: the only valid value for this are "12-hour" or "24-hour" 
      -->
    <default>24-hour</default>
    ...
  </locale>


Comment 2 Danilo Segan 2004-04-05 18:13:18 UTC
I've started that discussion in January, along with the patch.

http://pdx.freedesktop.org/pipermail/intltool/2004-January/000001.html

It was only for bare XML files (not .schemas files), but I've just updated it
for them as well.  The core of the patch is changed regular expression which
extracts the comment, if any.  One debatable point I decided on was that I
required the comment to be followed with at least one newline (\n).  I'm not
sure if that's good or not, but it's easily changed (the idea was to extract
comment from "previous line"; if "\n" is followed by a "?", we'd get "this or
previous line" instead).  I'll attach the patch here, along with README file
update (README update would make even more sense if certain string was chosen to
indicate that a comment really needs to be output, like "i18n:" or "translators:").

What blocked the patch at that time was that I didn't provide any tests (and
with current tests in intltool being seriously messed up, it's even harder to do
it, since they need to be rechecked completely), and that we should instead
switch to XML::Parser even in these cases (this is something I strongly object,
but this is not the place nor time for that discussion :).

One useful addition mentioned in the linked discussion was usage of specially
formated comment, instead of "any comment".  The proposal was to use "i18n:"
string to start such comments, and that can be easily changed with current patch.


Since .schemas files are treated specially, I think it might be nice to insert
some kind of comment for <default> values in all cases: they're usually expected
to be of certain form, and rarely do they need to be translated directly (more
commonly, they need to be chosen from a set of predefined values).  

I propose to do it with the comment like "Translators: this is default value for
a GConf setting. Be careful when translating."  Of course, when there already is
an author-provided comment, we would not output this one.

Please comment on the patch, and other ideas.
Comment 3 Danilo Segan 2004-04-05 18:16:09 UTC
Created attachment 26368 [details] [review]
Extract comments for translators for XML and .schemas files
Comment 4 Christian Neumair 2004-04-05 19:56:48 UTC
Danilo you are my very personal hero! :)

regs,
 Chris
Comment 5 Kenneth Rohde Christiansen 2004-04-09 15:16:07 UTC
The patch looks fine. If you add a test you can commit.
Comment 6 Danilo Segan 2004-04-09 23:46:28 UTC
I'll modify test.schemas.in (which currently fails anyway, because of move from
[]-style comments in schemas) with the following simple change:
--- results/test.schemas        Wed Oct 16 16:13:46 2002
+++ cases/test.schemas  Fri Apr  9 23:53:08 2004
@@ -7,13 +7,16 @@
         <owner>clock-applet</owner>
         <type>int</type>
         <locale name="C">
-          <default>24</default>
+          <default><!-- default value for
/schemas/apps/clock_applet/prefs/hour_format  
+                    The translation should only include the localized default
+                    eg. 12 or 24 -->
+                   24</default>
           <short>Hour format</short>
           <long>Sets the hour format, may be either 12 or 24</long>
         </locale>
 
         <locale name="schemasmerge1">
-          <default>12</default>
+          
           <short>Timformat</short>
           <long>Ställer in formatet på timmar, kan vara antingen 12 eller 24</long>
         </locale>

--- results/test.schemas.in.h   Thu Oct  3 16:21:31 2002
+++ cases/test.schemas.in.h     Fri Apr  9 23:53:08 2004
@@ -1,7 +1,10 @@
 char *s = N_("12");
+/*  default value for /schemas/apps/clock_applet/prefs/hour_format  
+                    The translation should only include the localized default
+                    eg. 12 or 24  */
+char *s = N_("24");
 char *s = N_("Display seconds in time");
 char *s = N_("Hour format");
 char *s = N_("Puh long.");
 char *s = N_("Sets the hour format, may be either 12 or 24");
 char *s = N_("Something random..even has >");
-char *s = N_("[default value for /schemas/apps/clock_applet/prefs/hour_format
The translation should only include the localized default eg. 12 or 24 ]24");


I've made a separate test for general XML comments handling.  It tries to go
through some corner-cases.
Comment 7 Danilo Segan 2004-04-09 23:49:10 UTC
Just another note, I'll commit this with appropriate tests one of these days
(I'll be out for a weekend, but I might be able to get Internet access during
this time).
Comment 8 Kenneth Rohde Christiansen 2004-04-26 08:54:53 UTC
Did you commit this yet?
Comment 9 Danilo Segan 2004-05-06 16:26:30 UTC
Hi all, sorry for not responding earlier, I was out of town.

This wasn't commited yet, because I found a bug when going through more testing,
but didn't have the time to mention it since I was going away.

The new patch requires the comment *not* to contain ">" in it, or it will not
detect it.  This means that some comments won't work, but it's still better than
what we have now.  I'll mention that in README as well.  There's a testcase to
check for this as well.

I have committed the following patch now. The bulk of the patch are testcases,
and it's otherwise same as the previous (that's why I went ahead and committed it).
Comment 10 Danilo Segan 2004-05-06 16:29:57 UTC
Comment on attachment 26368 [details] [review]
Extract comments for translators for XML and .schemas files

This one is obsolete now.
Comment 11 Danilo Segan 2004-05-06 16:33:37 UTC
Created attachment 27435 [details] [review]
Support for comments in XML files (with testcases)

I've committed this patch to CVS HEAD.
Comment 12 Danilo Segan 2004-05-06 16:36:11 UTC
Everyone, please test this now, and reopen if I made a mistake somewhere.  Sorry
again for being so slow on this.