[[!toc]]

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
========================================

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|contribute/build/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>

<a id="check-po"></a>

Check the validity of PO files
==============================

<div class="note">
Make sure you have read the [[documentation about Git
submodules|contribute/git#submodules]], otherwise this might not
work properly.
</div>

To check the validity of PO files, install [i18nspector](http://jwilk.net/software/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
    contribute/l10n_tricks/check_po.sh

You can get an explaination of each error message on the [[following documentation|https://readthedocs.org/projects/i18nspector/downloads/pdf/latest/]].

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|contribute/git]]: tails-greeter,
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|git-clean-po]] 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.

List Transifex translators
==========================

This script lists people who did translation work on Transifex.  You first need
to import those translation using the `./import-translations` script.

This is useful for:

  - a team using Git to get in touch regularly with the translators on Transifex
    so that they don't waste their time without anyone telling them.
  - a new team to recruit translator to work on the website.

Execute from the root of the Git repository:

    ./import-translations
    ./wiki/src/contribute/l10n_tricks/transifex_translators.sh

Get an overview of translation progress
=======================================

You can get a list of pages that are not 100% translated on [[this dedicated page|contribute/how/translate/translation_progress]].
