Hi,

https://bugs.debian.org/518218

On Wed, Sep 14, 2016 at 10:34:23PM +0200, Martin Quinson wrote:
> Hello Osamu,
> 
> I'm doing some basic bug triage in po4a, and it seems that you have a
> working patch for this bug. Could you please share it so that I can
> add it to the package?

I have found a good solution to this wishlist bug but that is not the
patch to the po4a tool.

So the solution is to add some "Howto" for the localization of the
XML/SGML document via po4a :-)

Due to the limitation of addendum feature as present in the po4a (see
Message #10) and unstable nature of the application of the locale
special patch files (see Message #10 and Message #18), I concluded that
the best way to add arbitrary locale specific XML content via entity
reference.

This is implemented in maint-guide.

Its main English XML file starts with:

|<?xml version="1.0" encoding="utf-8"?>
|<!-- -*- DocBook -*- -->
|<!-- vim:set tw=0 ts=8 et: -->
|<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"; [
|<!ENTITY % trans    SYSTEM "po/en.ent">   %trans;
|<!ENTITY % common   SYSTEM "common.ent">   %common;
|<!ENTITY % version  SYSTEM "version.ent">  %version;
|]>
|<book lang="en">
|<!-- This is UTF-8 encoded. -->
....
|<authorgroup>
|<!-- Do not use firstname and surname tags it breaks Japanese.  -->
|<!-- The same with othercredit -->
|<author> <personname>Josip Rodin</personname> <email>joy...@debian.org</email> 
<
|contrib>original contents</contrib> </author>
|<author> <personname>Osamu Aoki</personname> <email>os...@debian.org</email> 
<co
|ntrib>updated contents</contrib> </author>
|<!-- translator credits in po/translator.*.ent -->
|&othercredit;
|</authorgroup>
....

!!!! HERE IS THE TRICK !!!!

After normal po4a processing to get the translated text, say "fr", build
script changes: 
|<!ENTITY % trans    SYSTEM "po/en.ent">   %trans;
line with the following via sed:
|<!ENTITY % trans    SYSTEM "po/fr.ent">   %trans;

The po/en.ent is following:
|<!--
|This is UTF-8 file.
|Remember, the *first* definition of an entity wins.
|-->
|
|<!ENTITY othercredit ''>

So nothing wild happens.

The po/fr.ent is manually generated as the following:

|<!--
|This is UTF-8 file.
|Remember, the *first* definition of an entity wins.
|-->
|
|<!ENTITY othercredit '
|<othercredit role="translation"><personname>Frédéric 
Dumont</personname><email>f
|rederic.dum...@easynet.be</email><contrib>traduction 
française</contrib></otherc
|redit>
|<othercredit role="translation"><personname>Mohammed Adnène 
Trojette</personname
|><email>adn+...@diwi.org</email><contrib>traduction 
française</contrib></othercr
|edit>
|<othercredit role="translation"><personname>David 
Prévot</personname><email>davi
|d...@tilapin.org</email><contrib>traduction française</contrib></othercredit>
|<othercredit role="translation"><personname>les membres de la liste 
debian-l10n-
|french</personname><email>debian-l10n-fre...@lists.debian.org</email><contrib>tr
|aduction française</contrib></othercredit>
|'>
|
|<!-- overwrite Wikipiédia links available in French -->
|<!ENTITY autoconf "http://fr.wikipedia.org/wiki/Autoconf";>
|<!ENTITY automake "http://fr.wikipedia.org/wiki/GNU_Automake";>
|<!ENTITY cmake "http://fr.wikipedia.org/wiki/CMake";>
|<!ENTITY c-program "http://fr.wikipedia.org/wiki/C_(langage)">
|<!ENTITY cxx "http://fr.wikipedia.org/wiki/C++";>
|<!ENTITY elf "http://fr.wikipedia.org/wiki/Executable_and_Linkable_Format";>
|<!ENTITY gettext "http://fr.wikipedia.org/wiki/GNU_gettext";>
|<!ENTITY gnu-build-system "http://fr.wikipedia.org/wiki/Autotools";>
|<!ENTITY library "http://fr.wikipedia.org/wiki/Bibliothèque_logicielle";>
|<!ENTITY libtool "http://fr.wikipedia.org/wiki/GNU_Libtool";>
|<!ENTITY utf8 "http://fr.wikipedia.org/wiki/UTF-8";>
|
|<!-- overwrite Debian Wiki links available in French -->
|<!ENTITY debianwikihelp "http://wiki.debian.org/fr/HelpDebian";>
|
|<!-- The Developers' Reference is also available in French -->
|<!ENTITY developers-refpdf 
"/usr/share/doc/developers-reference-fr/developers-re
|ference.pdf">
|

As you can see here, the translator credit is added via entity file and
also some URL references can be overriden by this approach. 

Please note, this approach does not require any changes to po4a nor rely
on the addendum feature of po4a.  If one wishes to migrate to the new
gettext 0.19 as the po conversion tool for XML, this approach is usable.

Of course, I normalize the XML file by extracting URL references and
making them as a auto-generated entity file to get the 2nd part of this
localization feature.

See the actual code in:
  https://anonscm.debian.org/cgit/ddp/maint-guide.git/tree/

Regards,

Osamu

PS:  The po4a data directory is in po/ instead of po4a/

Reply via email to