Commit | Line | Data |
---|---|---|
5b824516 TS |
1 | # This source code is released in public domain. |
2 | ||
e9d73ead | 3 | # Author Tomas Stary (2016) <tomichec@gmail.com> |
380f711a | 4 | # Thanks for helpful discussion to Thérèse Godefroy |
5b824516 | 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: | |
e9d73ead | 12 | # https://po4a.org/man/man1/po4a.1.php |
b121008a TS |
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' \ | |
a8687551 | 24 | |
b121008a TS |
25 | # list of source files for the translation |
26 | SRC=confirmation.html\ | |
27 | index.html\ | |
28 | infographic.html\ | |
b121008a | 29 | next_steps.html\ |
b121008a TS |
30 | workshops.html |
31 | ||
32 | ############################################################ | |
e9d73ead | 33 | # Initialise the po template from English version, this is to be used, |
b121008a TS |
34 | # there is no translation for now, and you are going to build it from |
35 | # scratch. Then copy the file esd-temp.pot to your language file | |
36 | # esd-$(lang).po such as esd-cs.po, and edit it in your favourite PO | |
37 | # editor (such as poedit, or emacs with po-mode). | |
38 | ||
39 | # If you already have an old translation you can convert it to PO | |
40 | # files as described bellow. | |
41 | esd-temp.pot: $(foreach f,$(SRC),en/$f) | |
42 | po4a-gettextize $(PO4A_FLAGS) $(foreach f,$+,-m $f) -p $@ | |
43 | ||
44 | ############################################################ | |
45 | # Convert existing translations into PO files. | |
46 | ||
47 | # NOTE: You need to make sure that your translated document is formaly | |
48 | # correct xhtml (there might be accidental mistakes). | |
49 | # Validate your document to find errors (e.g. https://validator.w3.org) | |
50 | ||
51 | # IMPORTANT: when you generate the PO files from the existing | |
52 | # translation, the original files in the version *corresponding* to | |
53 | # the translation have to be provided as a command line argument (with | |
54 | # parameter -m). | |
55 | ||
56 | # for that specify the directory where the original files are placed | |
57 | DIR=en | |
58 | # and the list of files that were translated within the corresponding | |
59 | # version | |
60 | FILES=$(SRC) | |
61 | ||
62 | # The generation of the PO file is likely to go wrong, because of the | |
63 | # mistakes which were introduced by the direct translation of the html | |
64 | # files. In this case the po4a gives quite good error message with a | |
65 | # reference in which file and line number to look at to find the | |
66 | # mistake. Go to that file and try to correct the errors and then | |
67 | # repeat the procedure. | |
68 | ||
380f711a | 69 | # Don't give up. Translating PO files is nicer. |
b121008a TS |
70 | |
71 | # For more details and troubleshooting see: | |
380f711a | 72 | # https://po4a.org/man/man7/po4a.7.php |
b121008a TS |
73 | # in section: HOWTO convert a pre-existing translation to po4a? |
74 | esd-%.po.extract: $(foreach d,$(DIR) %,$(foreach f,$(FILES),$d/$f)) | |
75 | po4a-gettextize $(PO4A_FLAGS) $(foreach f,$(FILES),-m $(DIR)/$f) $(foreach f,$(FILES),-l $*/$f) -p $@ | |
76 | cp $@ `basename -s .extract $@` | |
77 | ||
78 | ############################################################ | |
e9d73ead | 79 | # Update the PO translation after the original has changed. This will |
b121008a TS |
80 | # make a new PO file automaticaly reusing identical translations, but |
81 | # the strings will be made fuzzy and need to verified manualy. Strings | |
82 | # that changed need to be translated again. | |
83 | esd-%.po.update: esd-%.po $(foreach f,$(SRC),en/$f) | |
84 | cp $< $@ | |
ffac1b0f TG |
85 | po4a-updatepo $(PO4A_FLAGS) $(foreach f,$(SRC),-m en/$f) -p $@; \ |
86 | ./gnun-add-fuzzy-diff $@ > $< | |
a8687551 | 87 | |
380f711a TG |
88 | # gnun-add-fuzzy-diff (from the GNUN package) is very useful to locate |
89 | # a change within a string. |