author | Edouard Tisserant |
Tue, 02 Feb 2021 11:17:03 +0100 | |
branch | svghmi |
changeset 3122 | 229795c03e11 |
parent 3116 | 6da94ec04325 |
child 3126 | f45e413a0f40 |
permissions | -rw-r--r-- |
3108
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
1 |
// i18n.ysl2 |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
2 |
|
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
3 |
|
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
4 |
template "svg:tspan", mode="extract_i18n" { |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
5 |
if "string-length(.) > 0" line { |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
6 |
value "."; |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
7 |
} |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
8 |
} |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
9 |
|
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
10 |
template "svg:text", mode="extract_i18n" { |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
11 |
msg { |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
12 |
attrib "id" value "@id"; |
3112
bd20f9112014
SVGHMI: still WIP, now POT file is properly generated with utf-8 encoding and POEdit is launched when pressing button.
Edouard Tisserant
parents:
3108
diff
changeset
|
13 |
attrib "label" value "substring(@inkscape:label,2)"; |
3108
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
14 |
apply "svg:*", mode="extract_i18n"; |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
15 |
} |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
16 |
} |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
17 |
|
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
18 |
const "translatable_texts", "//svg:text[starts-with(@inkscape:label, '_')]"; |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
19 |
const "translatable_strings" apply "$translatable_texts", mode="extract_i18n"; |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
20 |
|
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
21 |
emit "preamble:i18n" { |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
22 |
const "translations", "ns:GetTranslations($translatable_strings)"; |
3116
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
23 |
> var langs = [ |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
24 |
foreach "$translations/langs/lang" { |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
25 |
value "."; |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
26 |
if "position()!=last()" > , |
3108
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
27 |
} |
3116
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
28 |
| ]; |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
29 |
| var translations = [ |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
30 |
foreach "$translatable_texts" { |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
31 |
const "n","position()"; |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
32 |
> ["«@id»",[ |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
33 |
foreach "$translations/messages/msgid[$n]/msg" { |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
34 |
> " |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
35 |
foreach "line" { |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
36 |
value "."; |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
37 |
if "position()!=last()" > \\\\n |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
38 |
} |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
39 |
> " |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
40 |
if "position()!=last()" > , |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
41 |
} |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
42 |
> ]] |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
43 |
if "position()!=last()" > , |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
44 |
> \n |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
45 |
} |
6da94ec04325
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents:
3112
diff
changeset
|
46 |
| ] |
3108
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
47 |
} |