Commit | Line | Data |
---|---|---|
5b824516 TS |
1 | # This source code is released in public domain. |
2 | ||
3 | # Author Tomas Stary (2016) <tomichec@gmail.com> | |
4 | # Thanks for helpfull discussion to Thérèse Godefroy | |
5 | ||
b121008a TS |
6 | # This is a Makefile to generate the PO files for automated |
7 | # translation. If you get through the trouble of creating PO file for | |
8 | # your language, you will save a lot of hassles with editing plain html | |
9 | # and repeated text, which also implies potential mistakes. | |
10 | ||
11 | # Please read the manual on the page: | |
12 | # http://dev.man-online.org/man7/po4a/ | |
13 | ||
14 | # This Makefile only contains commands from the manual tested for the | |
15 | # esd translation. | |
16 | ||
17 | # After the translation of the PO file has been finished, generate new | |
18 | # files using: make -f Makefile.gen | |
19 | ||
20 | # flags for the po4a-getextize | |
a8687551 TS |
21 | PO4A_FLAGS=-M utf-8 -f xhtml -o porefs=none \ |
22 | -o 'untranslated=<script>' \ | |
23 | -o 'attributes=<meta>content' \ | |
24 | --package-name emailselfdefense --package-version $version | |
25 | ||
b121008a TS |
26 | # list of source files for the translation |
27 | SRC=confirmation.html\ | |
28 | index.html\ | |
29 | infographic.html\ | |
30 | mac.html\ | |
31 | next_steps.html\ | |
32 | windows.html\ | |
33 | workshops.html | |
34 | ||
35 | ############################################################ | |
36 | # initialise the po template from English version, this is to be used, | |
37 | # there is no translation for now, and you are going to build it from | |
38 | # scratch. Then copy the file esd-temp.pot to your language file | |
39 | # esd-$(lang).po such as esd-cs.po, and edit it in your favourite PO | |
40 | # editor (such as poedit, or emacs with po-mode). | |
41 | ||
42 | # If you already have an old translation you can convert it to PO | |
43 | # files as described bellow. | |
44 | esd-temp.pot: $(foreach f,$(SRC),en/$f) | |
45 | po4a-gettextize $(PO4A_FLAGS) $(foreach f,$+,-m $f) -p $@ | |
46 | ||
47 | ############################################################ | |
48 | # Convert existing translations into PO files. | |
49 | ||
50 | # NOTE: You need to make sure that your translated document is formaly | |
51 | # correct xhtml (there might be accidental mistakes). | |
52 | # Validate your document to find errors (e.g. https://validator.w3.org) | |
53 | ||
54 | # IMPORTANT: when you generate the PO files from the existing | |
55 | # translation, the original files in the version *corresponding* to | |
56 | # the translation have to be provided as a command line argument (with | |
57 | # parameter -m). | |
58 | ||
59 | # for that specify the directory where the original files are placed | |
60 | DIR=en | |
61 | # and the list of files that were translated within the corresponding | |
62 | # version | |
63 | FILES=$(SRC) | |
64 | ||
65 | # The generation of the PO file is likely to go wrong, because of the | |
66 | # mistakes which were introduced by the direct translation of the html | |
67 | # files. In this case the po4a gives quite good error message with a | |
68 | # reference in which file and line number to look at to find the | |
69 | # mistake. Go to that file and try to correct the errors and then | |
70 | # repeat the procedure. | |
71 | ||
72 | # Don't give it up translating PO files is nicer. | |
73 | ||
74 | # For more details and troubleshooting see: | |
75 | # http://dev.man-online.org/man7/po4a/ | |
76 | # in section: HOWTO convert a pre-existing translation to po4a? | |
77 | esd-%.po.extract: $(foreach d,$(DIR) %,$(foreach f,$(FILES),$d/$f)) | |
78 | po4a-gettextize $(PO4A_FLAGS) $(foreach f,$(FILES),-m $(DIR)/$f) $(foreach f,$(FILES),-l $*/$f) -p $@ | |
79 | cp $@ `basename -s .extract $@` | |
80 | ||
81 | ############################################################ | |
82 | # update the PO translation after the original has changed. This will | |
83 | # make a new PO file automaticaly reusing identical translations, but | |
84 | # the strings will be made fuzzy and need to verified manualy. Strings | |
85 | # that changed need to be translated again. | |
86 | esd-%.po.update: esd-%.po $(foreach f,$(SRC),en/$f) | |
87 | cp $< $@ | |
ffac1b0f TG |
88 | po4a-updatepo $(PO4A_FLAGS) $(foreach f,$(SRC),-m en/$f) -p $@; \ |
89 | ./gnun-add-fuzzy-diff $@ > $< | |
a8687551 TS |
90 | |
91 | # TODO: The system could be further refined with 2 external scripts: | |
92 | ||
93 | # - gnun-add-fuzzy-diff (from the GNUN package [4]). Very useful to locate | |
94 | # a change within a string. It runs after po4a-updatepo. | |
95 | ||
96 | # - some sort of reformatting script to get rid of the extra spaces, tabs, | |
97 | # linefeeds, etc., to make sure that a spurious difference between | |
98 | # index.html, mac.html and windows.html isn't going to add useless strings | |
99 | # to an existing POT file, or make the POs fuzzy for no reason. There is | |
100 | # such a script in the kitchen (reformat-html), but I am currently using a | |
101 | # simpler one (reformat-original, attached). |