Automatic gettext translation generator for testing (pseudolocalization)

902 views Asked by At

I'm currently in process of making site i18n-aware. Marking hardcoded strings as translatable.

I wonder if there's any automated tool that would let me browse the site and quickly see which strings are marked and which still aren't. I saw a few projects like django-i18n-helper that try to highlight translated strings using HTML facilities, but this doesn't work well with JavaScript.

So I thought FДЦЖ CУЯILLIC, or ʇxǝʇ uʍop-ǝpısdn (or something along those lines) should do the trick. Easy to distinguish visually, still readable, yet doesn't depend on any rich text formatting besides Unicode support.

The problem is, I can't find any readily-available tool that'd eat gettext .po/.pot file(s) and spew out such translation. Still, I think the idea is pretty obvious, so there must be something out there, already.

In my case I'm using Python/Django, but I suppose this question applies to anything that uses gettext-compatible library. The only thing the tool should be aware of, is that there could be HTML fragments in translation strings.

2

There are 2 answers

3
Wander Nauta On BEST ANSWER

The msgfilter program will let you run your translations through any program you want. It works especially well with GNU sed.

For example, to turn all your translations into uppercase (HTML is mostly case-insensitive, so this should work):

msgfilter -i django.po sed -e 's/\(.*\)/\U\1/'

The only strings in your app that have lowercase letters in them would then be the hardcoded ones.

If you really want to do faux cyrillic, you just have to write a program or script that reads Latin and outputs that, and feed that program to msgfilter instead of sed.

If your distribution has a talkfilters package, it might provide a few programs that might be useful in this specific case. All of these should work as msgfilter filters. (My personal favorite is chef. Bork bork bork!)

0
drdaeman On

Haven't tried this myself yet, but found podebug tool from Translate Toolkit. Based on documentation (flipped and unicode rewrite options), this looks exactly the tool I wished for.