Re: Looking for the original of the Spanish gnome-user-guide translation



Hi Daniel,

Yesterday at 23:25, Daniel Veillard wrote:
>
>   I don't understand a bit what you are saying there...

Let me try with a simple example.

C/user-guide.xml:
<?xml version="1.0"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
  <!ENTITY PART1 SYSTEM "part1.xml">
  <!ENTITY gosbasic SYSTEM "gosbasic.xml">  
]>
<?yelp:chunk-depth 3?>
<book id="index"> 
&PART1;
</book>

C/part1.xml:
<part id="part1-1">
<title>A Tour of the GNOME Desktop</title>
&gosbasic;
</part>

C/gosbasic.xml: doesn't matter what it is

I have translations to Serbian available for things like "A Tour of
the GNOME Desktop", "Blah blah." etc.  I want to produce translated
XML files for all of these.

So, my xml2po does the following when eg. merging translations into
sr/part1.xml: it reads in C/part1.xml using libxml2 parser, walks
through the DOM tree replacing text with translations (actually, it
works on bit more than text, but that's irrelevant now), and calls 
serialize() to output the same DOM tree to sr/part1.xml.  Because XML
is not well-formed, I get this:

I/O warning : failed to load external entity "C/part1.xml"
Error: cannot open file 'C/part1.xml'.

Now, in xml2po I currently ignore any errors so I would be at least
able to read the file in:

  def xml_error_handler(arg, ctxt):
      pass

  libxml2.registerErrorHandler(xml_error_handler, None)

With that approach, resulting sr/part1.xml would look like:
<part id="part1-1">
<title>Translated title</title>

</part>
(note the missing &gosbasic;).

I admit that I may be missing something obvious here, so that's why I
mentioned talking to you libxml2 guys ;-)

If I understood Shaun correctly, instead of producing translations in
multiple files, I'd simply do ctxt.replaceEntities(1) when I create
the parser, and I wouldn't have any problems.  This is trivial
solution, and I've just committed a change which allows one to use
xml2po with "-e" option to achieve such behaviour (so Shaun, if you've
got some time on your hands, can you check to see if this is what you
thought off?).

So now, in order to translate all of the user guide, one might want
to do:
   xml2po -e -o sr.po C/user-guide.xml # this will process all .xml files included from user-guide.xml
   # edit sr.po and translate user guide
   xml2po -e -p sr.po C/user-guide.xml > sr/user-guide.xml

Other solution I can think of is that I insert DTD (taken from
top-level XML file, in this case user-guide.xml) into input file, do
the rest of the work, .serialize() the document, and strip the DTD.
This is bound to be error-prone, of course, so I'd rather avoid it.


I certainly hope I'm missing on a simple feature of libxml2 to allow
entities to be kept in the DOM tree even if they're not declared, but
I'm not holding my breath.

Cheers,
Danilo



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]