sorting translation entries

Valient Gough vgough at pobox.com
Sun Jan 2 05:52:43 CST 2005


I've been sorting my translation strings (POT file) in rough order by 
most desired translations first, so translators will see them first in 
Rosetta.  I don't know how Rosetta plans on dealing with sorting (if at 
all), so I'll describe how I've handled it for my project.

I use comments in front of the translation strings to specify sort order 
using a small perl script po-group (http://pobox.com/~vgough/po-group) 
which parses a po file and sorts it based on the comments.  The comment 
that po-group sorts by is "xgroup([group name])".  For example, in my 
code I have tagged various common strings like this:

    // xgroup(common)
    printf( _("hello world") );

A couple changes are then required in the po/Makefile.in.in (from the 
default gettext setup):

- gettext's template Makefile uses the option 
"--add-comments=TRANSLATORS:" , which I replaced with just 
"--add-comments", so that all the comments preceeding a translated 
string will be pulled into the .pot file.

- po-group also needs to be automatically run.  In the gettext default 
Makefile.in.in, there are two places where the .pot file is created as a 
temporary file and then moved to the final location with "mv 
$(DOMAIN).po $(srcdir)/$(DOMAIN).pot;"  I replaced both those with  
"./po-group sort $(DOMAIN).po > $(srcdir)/$(DOMAIN).pot;"

The disadvantage of this scheme is that it is intrusive -- it requires 
that you add comments to mark the most important strings, and you make 
po-group get run from the makefile.

The advantage is that the sorting information will not go out-of-date 
even if the string is modified, because it is kept in the same place as 
the original string..

regards,
Valient





More information about the rosetta-users mailing list