- Compare the content of two PO files
- Calculate statistics on the translations
- Build a local copy of the website
- Search for fuzzy strings with Vim
- Check the validity of PO files
- Rewrap files
- Quickly update several repositories
- Remove autogenerated PO files
- List Transifex translators
- Get an overview of translation progress
- Build a translation memory to use with Poedit
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
- Install the
intltool
Debian package. - 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
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
contribute/l10n_tricks/check_po.sh
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.
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
See https://translate.tails.boum.org/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:
- Edit → Preferences → TM
- Learn from files
- Select your newly created file (
allspanish.po
in this case)