Re: Gnome2 User Guide: translate it!
- From: danilo gnome org (Danilo Šegan)
- To: Shaun McCance <shaunm gnome org>
- Cc: gnome-i18n gnome org, gnome-doc-list gnome org
- Subject: Re: Gnome2 User Guide: translate it!
- Date: Fri, 24 Feb 2006 18:54:55 +0100
Hi Shaun,
Today at 17:38, Shaun McCance wrote:
> We could probably come up with some clever system of using
> remarks to provide translator comments to entire blocks of
> translatable units. Then again, we could probably do some
> xml2po magic to do the same thing with comments. Imagine:
>
> <!-- Translators: Don't bother with this section yet -->
> <section id="fum">
> <title>Fum</title>
> <para>Paragraph 1</para>
> <para>Paragraph 2</para>
> <para>Paragraph 3</para>
> </section>
>
> With some clever programming, xml2po could detect the
> translator comment on the section element and distribute
> it across its ancestors. Danilo, thoughts?
It's not a problem to implement, except for the one part: doing it for
<section> and similar elements is DocBook-specific, while xml2po works
with much more than just DocBook, and mode-support doesn't provide for
such special commentary handling. I also think it would be overkill
to put that into modes until it proves necessary (i.e. we try to
support XML DTD which embeds translators' comments inside attributes
or special elements).
However, "carrying over" all the comments of the specific format might
be a good idea anyway, i.e. all comments case-insensitively matching
"^translators:.*".
I think it would work pretty well in practice, since you're unlikely
to otherwise put such comments if you don't want them to propagate,
and this would have the advantage of working for even <mediaobjects>
and similar stuff as well.
A comment wouldn't even be seen (now) if it doesn't directly precede
the translatable (as in "the one really being extracted") element
which it comments on. So, currently,
<!-- translators: this is blah, blah... -->
<listitem>
<para>Foo-bar stuff...</para>
</listitem>
wouldn't give the desired result (comment wouldn't be extracted).
Attached is a patch I'll probably commit (need to document this as
well)—it modifies only a single getCommentForNode() function and gives
more-expected behaviour (the above would work).
It's not the most efficient (regex matching might be run for several
times), but that might be a big deal only if the structure was very
deep like 100 levels, but I'll just test it a bit more with my
testcases (to see that it doesn't break anything) before committing.
Joachim: this means that the start comment starting with
"Translators:" or "translators:" should do the job if it's put right
before the section you want the comment to propagate for.
Cheers,
Danilo
--- xml2po.py~ 2006-02-14 02:49:42.000000000 +0100
+++ xml2po.py 2006-02-24 18:37:47.000000000 +0100
@@ -300,6 +300,12 @@
if prev and prev.type == 'comment':
return prev.content.strip()
else:
+ # Try to find a parent comment matching 'translators:.*' regex
+ parent = node.parent
+ if parent:
+ comment = getCommentForNode(parent)
+ if comment and re.match("^\s*translators:", comment, re.IGNORECASE):
+ return comment
return None
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]