svghmi/i18n.ysl2
changeset 3302 c89fc366bebd
parent 3144 2af6afaccaf2
child 3489 5335895ce526
equal deleted inserted replaced
2744:577118ebd179 3302:c89fc366bebd
       
     1 // i18n.ysl2
       
     2 
       
     3 
       
     4 template "svg:tspan", mode="extract_i18n" {
       
     5     if "string-length(.) > 0" line {
       
     6         value ".";
       
     7     }
       
     8 }
       
     9 
       
    10 template "svg:text", mode="extract_i18n" {
       
    11     msg {
       
    12         attrib "id" value "@id";
       
    13         attrib "label" value "substring(@inkscape:label,2)";
       
    14         apply "svg:*", mode="extract_i18n";
       
    15     }
       
    16 }
       
    17 
       
    18 const "translatable_texts", "//svg:text[starts-with(@inkscape:label, '_')]";
       
    19 const "translatable_strings" apply "$translatable_texts", mode="extract_i18n";
       
    20 
       
    21 emit "preamble:i18n" {
       
    22     const "translations", "ns:GetTranslations($translatable_strings)";
       
    23     > var langs = [ ["Default", "C"],
       
    24     foreach "$translations/langs/lang" {
       
    25         > ["«.»","«@code»"]
       
    26         if "position()!=last()" > ,
       
    27     }
       
    28     | ];
       
    29     | var translations = [
       
    30     foreach "$translatable_texts" {
       
    31         const "n","position()";
       
    32         const "current_id","@id";
       
    33         const "text_unlinked_uses","$result_svg_ns//svg:text[@original = $current_id]/@id";
       
    34     >   [[
       
    35         foreach "@id | $text_unlinked_uses" {
       
    36             > id("«.»")
       
    37             if "position()!=last()" > ,
       
    38         }
       
    39     > ],[
       
    40         foreach "$translations/messages/msgid[$n]/msg" {
       
    41             > "
       
    42             foreach "line" {
       
    43                 value ".";
       
    44                 if "position()!=last()" > \\\\n
       
    45             }
       
    46             > "
       
    47             if "position()!=last()" > ,
       
    48         }
       
    49         > ]]
       
    50         if "position()!=last()" > ,
       
    51         > \n
       
    52     }
       
    53     | ]
       
    54 }