Compare the content of two PO files

Here is how to check out the differences between two PO files without caring about strings order, line breaks or comments.

diff -u <(msgfmt -o - translation/es/es.po | msgunfmt) \
        <(msgfmt -o - persistence-setup/po/es.po | msgunfmt)

The syntax is bash specific. Replace the paths to the two PO files you are interested in comparing.

Calculate statistics on the translations

  1. Install the intltool Debian package.
  2. Run the language statistics.sh script.

Build a local copy of the website

To check your translations before sending them, we recommend you build a local copy of the website.

Search for fuzzy strings with Vim

Ran inside Vim, the following command will search recursively for fuzzy inside .fr.po files

:vimgrep /fuzzy/ **/*.fr.po |:copen

To switch easily between the file list and the editor, using Alt + Arrow up/down, you can add those lines in .vimrc:

nmap <silent> <A-Up> :wincmd k<CR>
nmap <silent> <A-Down> :wincmd j<CR>

Check the validity of PO files

Make sure you have read the documentation about Git submodules, otherwise this might not work properly.

To check the validity of PO files, install i18nspector by running the following command line:

sudo apt install i18nspector

You can then check a single file:

i18nspector <PO file>

or the whole wiki:

cd wiki/src
../../submodules/jenkins-tools/slaves/check_po

You can get an explaination of each error message on the following documentation.

Rewrap files

To rewrap one .po file:

msgcat --width=80 -o your_output_file.po your_input_file.po

To rewrap several .po files:

for f in $(find . -type f -name .po) ; do msgcat --width=80 -o \
     "${f}.new" "$f" ; mv -f "${f}.new" "$f" ; done

To rewrap a .mdwn file:

fold -s -w 80 translate.mdwn > translate.mdwn.out

Quickly update several repositories

Tails is split in several git repositories: whisperback, persistence-setup, etc.

If you cloned those differents repositories in the same folder, you can pull them all in a row with the following bash script:

#!/bin/sh
    for d in $(find . -type d -name ".git" | sed 's/\/.git\+$//' ); do
       echo "Current repository: $d";
       cd $d && git pull && cd - || exit 1
done

This will basically check in all subfolders if there is an existing .git folder, and run git pull if appropriate.

Remove autogenerated PO files

When building the wiki, ikiwiki often generates many PO files that you don't need to take into account or commit if you are working on the documentation or only on one language. This script does a checkout on all of the modified PO files in your working tree. Make sure to do git add on the files that you modified before running it, otherwise your changes will be lost.

Get an overview of translation progress

See https://translate.tails.net/projects/tails/#languages on our Weblate instance.

Build a translation memory to use with Poedit

For example for Spanish files, from the Git repo:

find wiki/src/ -name "*.es.po" > allspanish && \
msgcat --files-from=allspanish --output=allspanish.po

You can then configure it on your Poedit:

  1. EditPreferencesTM
  2. Learn from files
  3. Select your newly created file (allspanish.po in this case)