Skip to content

Commit 0c77628

Browse files
committed
XLIFF 1.2 -> 2.2
1 parent 3bf3732 commit 0c77628

1 file changed

Lines changed: 23 additions & 24 deletions

File tree

code/foundation-exam/translation.rkt

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@
9494
(define (text-body localized)
9595
(list (pcdata% (localized-text localized))))
9696

97-
; FIXME: what if no translations are needed
98-
9997
(define (translations->xliff-file source-language target-language filename id translations)
10098
(let ((trans-units
10199
(filter
@@ -107,30 +105,29 @@
107105
(equal? "" (localized-text target-localized))
108106
(not (localized-outdated? target-localized)))
109107
#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"))))))))))
123125
(range (length translations))
124126
translations))))
125127
(and (pair? trans-units)
126128
(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))))
134131

135132
(define (file->xliff source-language target-language filename)
136133
(let-values (((id translations) (file-collect-translations filename))
@@ -143,8 +140,10 @@
143140
'())
144141
(element% 'xliff
145142
(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))
148147
(filter values
149148
(map (lambda (filename)
150149
(file->xliff source-language target-language filename))

0 commit comments

Comments
 (0)