| 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 |
| 24 | LANG=sq |
| 25 | |
| 26 | # flags for the po4a-getextize |
| 27 | PO4A_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 |
| 32 | SRC=confirmation.html\ |
| 33 | index.html\ |
| 34 | infographic.html\ |
| 35 | next_steps.html\ |
| 36 | workshops.html |
| 37 | |
| 38 | # default target |
| 39 | all: $(foreach l,$(LANG),$(foreach f,$(SRC),$l/$f)) |
| 40 | |
| 41 | |
| 42 | ## Function to select gsed if sed is not GNU sed but BSD sed |
| 43 | define sedi |
| 44 | sed --version >/dev/null 2>&1 && sed -i || gsed -i |
| 45 | endef |
| 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 | cs/%.html: esd-cs.po $(foreach f,$(SRC),en/$f) |
| 64 | -po4a-translate $(PO4A_FLAGS) -m en/$*.html -p $< -l $@ |
| 65 | sed -i 's|img/en/|img/cs/|g' $@ |
| 66 | |
| 67 | # es - Spanish |
| 68 | es/%.html: esd-es.po $(foreach f,$(SRC),en/$f) |
| 69 | -po4a-translate $(PO4A_FLAGS) -m en/$*.html -p $< -l $@ |
| 70 | sed -i '/\/css\/main.css/a\ |
| 71 | <link rel="stylesheet" href="../static/css/main.es.css" />' $@ |
| 72 | sed -i 's,static/img/en/\([^/]\+.png\),static/img/es/\1,g' $@ |
| 73 | sed -i 's,static/img/en\(/screenshots/section.\+.png\),static/img/es\1,g' $@ |
| 74 | sed -i 's,static/img/en\(/screenshots/step1a.\+.png\),static/img/es\1,g' $@ |
| 75 | |
| 76 | # gl - Galician |
| 77 | gl/%.html: esd-gl.po $(foreach f,$(SRC),en/$f) |
| 78 | -po4a-translate $(PO4A_FLAGS) -m en/$*.html -p $< -l $@ |
| 79 | sed -i '/\/css\/main.css/a\ |
| 80 | <link rel="stylesheet" href="../static/css/main.es.css" />' $@ |
| 81 | sed -i 's,static/img/en/\([^/]\+.png\),static/img/es/\1,g' $@ |
| 82 | sed -i 's,static/img/en\(/screenshots/section.\+.png\),static/img/es\1,g' $@ |
| 83 | sed -i 's,static/img/en\(/screenshots/step1a.\+.png\),static/img/es\1,g' $@ |
| 84 | |
| 85 | # de - German |
| 86 | de/%.html: esd-de.po $(foreach f,$(SRC),en/$f) |
| 87 | -po4a-translate $(PO4A_FLAGS) -m en/$*.html -p $< -l $@ |
| 88 | sed -i '{s|img/en/|img/de/|g;}' $@ |
| 89 | sed -i '/\/css\/main.css/a\ |
| 90 | <link rel="stylesheet" href="../static/css/main.de.css" />' $@ |
| 91 | |
| 92 | # fa - Persian |
| 93 | fa/%.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/css/main.rtl.css" />' $@ |
| 98 | |
| 99 | # ja - Japanese |
| 100 | ja/%.html: esd-ja.po $(foreach f,$(SRC),en/$f) |
| 101 | -po4a-translate $(PO4A_FLAGS) -m en/$*.html -p $< -l $@ |
| 102 | |
| 103 | # pl - Polish |
| 104 | pl/%.html: esd-pl.po $(foreach f,$(SRC),en/$f) |
| 105 | -po4a-translate $(PO4A_FLAGS) -m en/$*.html -p $< -l $@ |
| 106 | |
| 107 | # pt-br - Brazilian Portuguese |
| 108 | pt-br/%.html: esd-pt-br.po $(foreach f,$(SRC),en/$f) |
| 109 | -po4a-translate $(PO4A_FLAGS) -m en/$*.html -p $< -l $@ |
| 110 | sed -i '/\/donate.png" \/><\/a><\/p>/a\ |
| 111 | \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>' $@ |
| 112 | |
| 113 | # sq - Albanian |
| 114 | sq/%.html: esd-sq.po $(foreach f,$(SRC),en/$f) |
| 115 | -po4a-translate $(PO4A_FLAGS) -m en/$*.html -p $< -l $@ |
| 116 | |
| 117 | # zh-han - Chinese (Han) |
| 118 | zh-hans/%.html: esd-zh-hans.po $(foreach f,$(SRC),en/$f) |
| 119 | -po4a-translate $(PO4A_FLAGS) --keep 0 -m en/$*.html -p $< -l $@ |
| 120 | sed -i 's|img/en/|img/zh-hans/|g' $@ |
| 121 | sed -i '/\/css\/main.css/a\ |
| 122 | <link rel="stylesheet" href="../static/css/main.zh-hans.css" />' $@ |
| 123 | |
| 124 | # tr - Turkish |
| 125 | tr/%.html: esd-tr.po $(foreach f,$(SRC),en/$f) |
| 126 | -po4a-translate $(PO4A_FLAGS) --keep 0 -m en/$*.html -p $< -l $@ |
| 127 | sed -i 's|img/en/|img/tr/|g' $@ |
| 128 | sed -i 's,\(alt="Bağış[^"]*"\),style="width:160px" \1,' $@ |
| 129 | |
| 130 | # fr - French |
| 131 | fr/%.html: esd-fr.po $(foreach f,$(SRC),en/$f) |
| 132 | -po4a-translate $(PO4A_FLAGS) --keep 0 -m en/$*.html -p $< -l $@ |
| 133 | sed -i 's|img/en/|img/fr/|g' $@ |
| 134 | # ru |
| 135 | ru/%.html: esd-ru.po $(foreach f,$(SRC),en/$f) |
| 136 | -po4a-translate $(PO4A_FLAGS) --keep 0 -m en/$*.html -p $< -l $@ |
| 137 | sed -i 's|img/en/|img/ru/|g' $@ |