|
94 | 94 | (define (text-body localized) |
95 | 95 | (list (pcdata% (localized-text localized)))) |
96 | 96 |
|
97 | | -; FIXME: what if no translations are needed |
98 | | - |
99 | 97 | (define (translations->xliff-file source-language target-language filename id translations) |
100 | 98 | (let ((trans-units |
101 | 99 | (filter |
|
107 | 105 | (equal? "" (localized-text target-localized)) |
108 | 106 | (not (localized-outdated? target-localized))) |
109 | 107 | #f ; nothing to do |
110 | | - (element% 'trans-unit |
111 | | - (list (attribute% 'id (string-append id "/" (number->string index)))) |
112 | | - (list* |
113 | | - (element% 'source '() (text-body source-localized)) |
114 | | - (element% 'target '() |
115 | | - (list (comment "translation goes here"))) |
116 | | - (map (lambda (localized) |
117 | | - (element% 'alt-trans '() |
118 | | - (list |
119 | | - (element% 'target |
120 | | - (list (attribute% 'xml:lang (localized-language localized))) |
121 | | - (text-body localized))))) |
122 | | - rest-localizeds)))))) |
| 108 | + (element% 'unit |
| 109 | + (list (attribute% 'id (string-append id "_" (number->string index)))) |
| 110 | + (list |
| 111 | + (element% 'notes '() |
| 112 | + (map (lambda (localized) |
| 113 | + (element% 'note |
| 114 | + (list |
| 115 | + (attribute% 'appliesTo "target") |
| 116 | + (attribute% 'category "translation") |
| 117 | + (attribute% 'xml:lang (localized-language localized))) |
| 118 | + (text-body localized))) |
| 119 | + rest-localizeds)) |
| 120 | + (element% 'segment '() |
| 121 | + (list |
| 122 | + (element% 'source '() (text-body source-localized)) |
| 123 | + (element% 'target '() |
| 124 | + (list (comment "translation goes here")))))))))) |
123 | 125 | (range (length translations)) |
124 | 126 | translations)))) |
125 | 127 | (and (pair? trans-units) |
126 | 128 | (element% 'file |
127 | | - (list (attribute% 'original filename) |
128 | | - (attribute% 'source-language source-language) |
129 | | - (attribute% 'target-language target-language) |
130 | | - (attribute% 'datatype "plaintext")) |
131 | | - (list (element% 'body |
132 | | - '() |
133 | | - trans-units)))))) |
| 129 | + (list (attribute% 'id filename)) |
| 130 | + trans-units)))) |
134 | 131 |
|
135 | 132 | (define (file->xliff source-language target-language filename) |
136 | 133 | (let-values (((id translations) (file-collect-translations filename)) |
|
143 | 140 | '()) |
144 | 141 | (element% 'xliff |
145 | 142 | (list |
146 | | - (attribute% 'version "1.2") |
147 | | - (attribute% 'xmlns "urn:oasis:names:tc:xliff:document:1.2")) |
| 143 | + (attribute% 'version "2.2") |
| 144 | + (attribute% 'xmlns "urn:oasis:names:tc:xliff:document:2.2") |
| 145 | + (attribute% 'srcLang source-language) |
| 146 | + (attribute% 'trgLang target-language)) |
148 | 147 | (filter values |
149 | 148 | (map (lambda (filename) |
150 | 149 | (file->xliff source-language target-language filename)) |
|
0 commit comments