bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: How to generate a "dialect" with gettext


From: Chusslove Illich
Subject: Re: How to generate a "dialect" with gettext
Date: Thu, 7 Jan 2010 18:13:07 +0100
User-agent: KMail/1.12.2 (Linux/2.6.16.60-0.21-smp; KDE/4.3.2; x86_64; svn-1022026; 2009-09-09)

(A better list for this question would have been
address@hidden, since this one deals with bugs and
feature requests for Gettext.)

> [: Marcel J. :]
> I want to use .po files, that have already been translated and only change
> some words in those files. Up to this point, there's no problem.

Right.

> However, I don't know how to deal with updates of the "official"
> translation.

There are many things that can be considered here, and they depend on the
precise differences between dialects and how and if the involved parties are
willing to cooperate. It can get hairy, with the final result of the "non-
official" translation being left unmaintained -- I know, because my language
has two *official* dialects :)

So rather than going deeper into that, let's just see your algorithm:

>        if a phrase is the same in <o-.po2.0> and <o-.po1.0>
>            this phrase should be the same in <d-.po2.0> and <d-.po1.0>

Fine.

>        if a phrase is different in <o-.po2.0> and <o-.po1.0>
>            this phrase should be the same in <d-.po2.0> and <o-.po2.0>
>            and get a "fuzzy"-flag
>        if a phrase is new in <o-.po2.0>
>            this phrase should be the same in <d-.po2.0> and <o-.po2.0>
>            and get a "fuzzy"-flag

What is "different" as opposed to "new" is open to interpretation. Luckily,
these two conditions fold into one action, no? That is, if the o-2 message
by its msgid field is not found in the o-1 catalog, then copy it into the
d-2 catalog and set fuzzy.

>        if a phrase was deleted in <o-.po2.0>
>            this phrase should not be in <d-.po2.0>

Fine.

If you fetch and setup the (not yet released) Pology¹ package:

  $ cd $SOMEWHERE
  $ svn co svn://anonsvn.kde.org/home/kde/trunk/l10n-support/pology
  $ export PYTHONPATH=$PWD:$PYTHONPATH

then the following Python function implements the above algorithm:

  def update_to_new_official (catpath_o1, catpath_d1, catpath_o2, catpath_d2):

      from pology.file.catalog import Catalog

      cat_o1 = Catalog(catpath_o1)
      cat_d1 = Catalog(catpath_d1)
      cat_o2 = Catalog(catpath_o2)

      cat_d2 = Catalog(catpath_d2, create=True, truncate=True)
      cat_d2.header = cat_d1.header

      for msg_o2 in cat_o2:
          if not msg_o2.active:
              continue
          msg_o1 = cat_o1.get(msg_o2)
          msg_d1 = cat_d1.get(msg_o2)
          if msg_o1 and msg_d1 and msg_o2.msgstr == msg_o1.msgstr:
              cat_d2.add_last(msg_d1)
          else:
              cat_d2.add_last(msg_o2)
              msg_o2.fuzzy = True

      cat_d2.sync()

A script that uses this function is attached. It can be called as:

  $ update_to_new_official.py official-1.po dialect-1.po official-2.po 
dialect-2.po

to write out the new dialect PO dialect-2.po, or as:

  $ update_to_new_official.py official-1.po dialect.po official-2.po dialect.po

to update the existing dialect PO.

[1] http://techbase.kde.org/Localization/Tools/Pology -- just a sketchy
overview, but there is internal reference documentation for most of the
stuff in doc/html/index.html in the file tree.

-- 
Chusslove Illich (Часлав Илић)

Attachment: update_to_new_official.py
Description: Text Data

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]