summaryrefslogtreecommitdiffstats
path: root/wiki/src/contribute/l10n_tricks.mdwn
blob: e646dd34ea71d16af7ade1d1ccc2d28cfcc2af37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
[[!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-get install i18nspector/wheezy-backports

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]].