svghmi/i18n.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Tue, 09 Feb 2021 07:56:25 +0100
branchsvghmi
changeset 3130 bdd81e12e7b5
parent 3126 f45e413a0f40
child 3133 450cd01324ad
permissions -rw-r--r--
SVGHMI: removed dead code
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" {
3126
f45e413a0f40 SVGHMI: generate JS translation literals so that it is possible to also translate uses of texts, and added JS code that apply translations to tspans
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3116
diff changeset
    25
        > "«.»"
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
    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()";
3126
f45e413a0f40 SVGHMI: generate JS translation literals so that it is possible to also translate uses of texts, and added JS code that apply translations to tspans
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3116
diff changeset
    32
        const "current_id","@id";
f45e413a0f40 SVGHMI: generate JS translation literals so that it is possible to also translate uses of texts, and added JS code that apply translations to tspans
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3116
diff changeset
    33
        const "text_unlinked_uses","$result_svg_ns//svg:text[@original = $current_id]/@id";
f45e413a0f40 SVGHMI: generate JS translation literals so that it is possible to also translate uses of texts, and added JS code that apply translations to tspans
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3116
diff changeset
    34
    >   [[
f45e413a0f40 SVGHMI: generate JS translation literals so that it is possible to also translate uses of texts, and added JS code that apply translations to tspans
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3116
diff changeset
    35
        foreach "@id | $text_unlinked_uses" {
f45e413a0f40 SVGHMI: generate JS translation literals so that it is possible to also translate uses of texts, and added JS code that apply translations to tspans
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3116
diff changeset
    36
            > id("«.»")
f45e413a0f40 SVGHMI: generate JS translation literals so that it is possible to also translate uses of texts, and added JS code that apply translations to tspans
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3116
diff changeset
    37
            if "position()!=last()" > ,
f45e413a0f40 SVGHMI: generate JS translation literals so that it is possible to also translate uses of texts, and added JS code that apply translations to tspans
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3116
diff changeset
    38
        }
f45e413a0f40 SVGHMI: generate JS translation literals so that it is possible to also translate uses of texts, and added JS code that apply translations to tspans
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3116
diff changeset
    39
    > ],[
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
    40
        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
    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
            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
    43
                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
    44
                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
    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
            > "
6da94ec04325 SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents: 3112
diff changeset
    47
            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
    48
        }
6da94ec04325 SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents: 3112
diff changeset
    49
        > ]]
6da94ec04325 SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents: 3112
diff changeset
    50
        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
    51
        > \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
    52
    }
6da94ec04325 SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
Edouard Tisserant
parents: 3112
diff changeset
    53
    | ]
3108
079419e7228d SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    54
}