[xliff-tools] Re: new gettext developments

Bruno Haible bruno at clisp.org
Wed Apr 4 15:52:48 PDT 2007


Asgeir Frimannsson wrote:
> When you talk about "newer PO features" - I am aware of the new msgctx
> field. Are there other new PO features that are not yet discussed in the
> representation guide?

There are two new syntax elements in PO files:

1) The msgctxt. Added in gettext 0.15.

  - PO files can now contain messages constrained to a certain context.
    Most often such a context is a menu, dialog or panel identification.
    The syntax in the PO file is
      msgctxt "context"
      msgid "original"
      msgstr "translation"
  - The xgettext program can be told through the --keyword flag which
    function/macro argument has the role of a context.  It also supports
    the GNOME glib convention to specify the context and original string
    in the same string literal: "context|original".
  - The (non-public) include file gettext.h defines macros pgettext, dpgettext
    etc. that take a context argument.
  For more information, see the node "Contexts" in the manual.

  A msgctxt line maps naturally to a <context-group> element containing a
  <context> element. For example,

    msgctxt "LDAPAuth"
    msgid "Please type in your password:"
    msgstr "Fyll inn passordet ditt her:"

  maps to

      <trans-unit xml:space="preserve" approved="yes" id="messages:1" resname="ee710ec49fd73392a62b8ab4e280e653">
        <source>Please type in your password:</source>
        <target>Fyll inn passordet ditt her:</target>
        <context-group name="po-1025" purpose="match information">
          <context context-type="x-unknown" match-mandatory="yes">LDAPAuth</context>
        </context-group>
      </trans-unit>

2) The "previous msgid" and "previous msgctxt" fields. Added in gettext 0.16:

  msgmerge has a new option --previous that has the effect of saving the
  previous msgid of message when making them fuzzy. These previous msgids are
  stored in the resulting PO file, using a pseudo-comment syntax like this:
  
     #, fuzzy
     #| msgid "too many arguments"
     msgid "too few arguments" 
     msgstr "trop d'arguments"
  
  The translator then only needs to compare the previous and the current
  msgid ("too many arguments" and "too few arguments"), and infer which
  parts of the translation she needs to change.

  msgattrib has a new option --clear-previous that removes these #| lines.

  The above example IMO maps most naturally to

     <trans-unit ...>
       <source xml:lang="en">too few arguments</source>
       <alt-trans xml:space="preserve" ...>
         <source xml:lang="en">too many arguments</source>
         <target xml:lang="fr">trop d'arguments</target>
       </alt-trans>
     </trans-unit>

Bruno



More information about the xliff-tools mailing list