Merge branch 'master' of https://vcs.fsf.org/git/enc
[enc.git] / Makefile.gen
... / ...
CommitLineData
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
6# This Makefile.gen is used to generate the translated html files from the
7# PO templates
8
9# See Makefile for generation of translation files (po, pot) and
10# extraction of translated strings from existing translation
11
12# usage: make -f Makefile.gen
13
14# IMPORTANT
15# 1. Make sure your esd-LANG.po is encoded in unix format (end
16# of line \n, not DOS \n\r), otherwise po4a-translate complains
17# about strange lines.
18# 2. Before generating a page for publication, make sure the PO has no
19# untranslated or fuzzy strings, otherwise the translation will be
20# interspersed with English strings.
21
22
23# In LANG add the code(s) of the language(s) you intend to translate
24LANG=tr
25
26# flags for the po4a-getextize
27PO4A_FLAGS=-M utf-8 -f xhtml --keep 30 -o porefs=none \
28 -o 'untranslated=<script>' \
29 -o 'attributes=<meta>content'
30
31# List of source files for the translation
32SRC=confirmation.html\
33 index.html\
34 infographic.html\
35 next_steps.html\
36 workshops.html
37
38# default target
39all: $(foreach l,$(LANG),$(foreach f,$(SRC),$l/$f))
40
41
42## Function to select gsed if sed is not GNU sed but BSD sed
43define sedi
44 sed --version >/dev/null 2>&1 && sed -i || gsed -i
45endef
46
47
48## RECIPES for the individual pages in each language
49
50# Add yours if you migrate to PO, keeping the alphabetical order.
51
52# NOTES
53# 1. You can use another recipe as a model, but be careful with global image
54# localization; make sure that _all_ images are in the static/LANG/img
55# subdirectory.
56# 2. The following modifications are essential for right to left languages:
57# sed -i 's|<html|<html dir="rtl"|' $@
58# sed -i '/\/css\/main.css/a\
59# <link rel="stylesheet" href="//static.fsf.org/nosvn/enc-dev0/css/main.rtl.css" />' $@
60# See Persian recipe as an example.
61
62# cs - Czech
63# sed -i 's|<li><a href="/en">English - v4.0</a></li>|<li><a class="current" href="/cs">Čeština - v4.0</a></li>\
64# <li><a href="/en">English - v4.0</a></li>|' $@
65cs/%.html: esd-cs.po $(foreach f,$(SRC),en/$f)
66 -po4a-translate $(PO4A_FLAGS) -m en/$*.html -p $< -l $@
67 sed -i 's|img/en/|img/cs/|g' $@
68
69# es - Spanish
70es/%.html: esd-es.po $(foreach f,$(SRC),en/$f)
71 -po4a-translate $(PO4A_FLAGS) -m en/$*.html -p $< -l $@
72 sed -i '/\/css\/main.css/a\
73 <link rel="stylesheet" href="//static.fsf.org/nosvn/enc-dev0/css/main.es.css" />' $@
74 sed -i 's,static.fsf.org/nosvn/enc-dev0/img/en,static.fsf.org/nosvn/enc-dev0/img/es,g' $@
75 sed -i 's,emailselfdefense.fsf.org/en/infographic.html,emailselfdefense.fsf.org/es/infographic.html,' $@
76
77# gl - Galician
78gl/%.html: esd-gl.po $(foreach f,$(SRC),en/$f)
79 -po4a-translate $(PO4A_FLAGS) -m en/$*.html -p $< -l $@
80 sed -i '/\/css\/main.css/a\
81 <link rel="stylesheet" href="//static.fsf.org/nosvn/enc-dev0/css/main.es.css" />' $@
82 sed -i 's,static.fsf.org/nosvn/enc-dev0/img/en,static.fsf.org/nosvn/enc-dev0/img/gl,g' $@
83 sed -i 's,emailselfdefense.fsf.org/en/infographic.html,emailselfdefense.fsf.org/gl/infographic.html,' $@
84
85# de - German
86de/%.html: esd-de.po $(foreach f,$(SRC),en/$f)
87 -po4a-translate $(PO4A_FLAGS) -m en/$*.html -p $< -l $@
88 $(sedi) '{s|img/en/|img/de/|g;}' $@
89 $(sedi) '/\/css\/main.css/a\
90 <link rel="stylesheet" href="//static.fsf.org/nosvn/enc-dev0/css/main.de.css" />' $@
91
92# fa - Persian
93fa/%.html: esd-fa.po $(foreach f,$(SRC),en/$f)
94 -po4a-translate $(PO4A_FLAGS) -m en/$*.html -p $< -l $@
95 sed -i 's|<html|<html dir="rtl"|' $@
96 sed -i '/\/css\/main.css/a\
97 <link rel="stylesheet" href="//static.fsf.org/nosvn/enc-dev0/css/main.rtl.css" />' $@
98
99# ja - Japanese
100ja/%.html: esd-ja.po $(foreach f,$(SRC),en/$f)
101 -po4a-translate $(PO4A_FLAGS) -m en/$*.html -p $< -l $@
102
103# pt-br - Brazilian Portuguese
104pt-br/%.html: esd-pt-br.po $(foreach f,$(SRC),en/$f)
105 -po4a-translate $(PO4A_FLAGS) -m en/$*.html -p $< -l $@
106 sed -i '/\/donate.png" \/><\/a><\/p>/a\
107 \n<div class="fsf-emphasis"><p>Conheça também a <a\nhref="http://www.fsfla.org/ikiwiki/index.pt.html">FSFLA</a>, organização\nirmã da FSF na América Latina.</p></div>' $@
108
109# sq - Albanian
110sq/%.html: esd-sq.po $(foreach f,$(SRC),en/$f)
111 -po4a-translate $(PO4A_FLAGS) -m en/$*.html -p $< -l $@
112
113# zh-han - Chinese (Han)
114zh-hans/%.html: esd-zh-hans.po $(foreach f,$(SRC),en/$f)
115 -po4a-translate $(PO4A_FLAGS) --keep 0 -m en/$*.html -p $< -l $@
116 sed -i 's|img/en/|img/zh-hans/|g' $@
117 sed -i '/\/css\/main.css/a\
118 <link rel="stylesheet" href="//static.fsf.org/nosvn/enc-dev0/css/main.zh-hans.css" />' $@
119
120# tr - Turkish
121tr/%.html: esd-tr.po $(foreach f,$(SRC),en/$f)
122 -po4a-translate $(PO4A_FLAGS) --keep 0 -m en/$*.html -p $< -l $@
123 sed -i 's|img/en/|img/tr/|g' $@
124 sed -i '/alt="Bağış"/ i\
125 style="width:160px"' $@
126
127# fr - French
128fr/%.html: esd-fr.po $(foreach f,$(SRC),en/$f)
129 -po4a-translate $(PO4A_FLAGS) --keep 0 -m en/$*.html -p $< -l $@
130 sed -i '/\/css\/main.css/a\
131 <link rel="stylesheet" ../static/css/main.fr.css" />' $@
132 sed -i 's|img/en/\([^/]\+\.png\)|img/fr/\1|g' $@
133 sed -i 's|img/en/\(screenshots/section.*\.png\)|img/fr/\1|g' $@
134 sed -i 's|img/en/\(screenshots/workshops.*\.png\)|img/fr/\1|g' $@