Hi,
(: param $lang is the desired target language of the translation :)
declare %rest:path("/admin/convert-to-xliff")
%rest:GET
%rest:query-param("lang", "{$lang}", '')
updating function admin:convert-to-xliff($lang as xs:string){
(: Src language is assumed to always be en-us as per business rules:)
let $src-lang := "en-us"
for $x in app:open-db($src-lang)
let $xliff-stylesheet := app:get-translation-xliff-to-xsl()
let $skeleton-stylesheet := app:get-translation-xliff-skeleton-xsl()
let $params := map {"lang-to" := $lang}
let $target-uri := replace(base-uri($x), $src-lang, $lang)
let $target-skeleton-uri := replace($target-uri, '.xml', '_xliffskeleton.xml')
let $xliff-doc := xslt:transform($x, $xliff-stylesheet, $params)
let $xliff-skeleton := xslt:transform($x, $skeleton-stylesheet)
return db:replace("Translated-units", $target-uri, document{$xliff-doc}), db:replace("Translated-units", $target-skeleton-uri, document {$xliff-skeleton})
};
(: db:replace("Translated-units", $target-uri, document{$xliff-doc}) --- Creates the expected files in the expected location :)
(: db:replace("Translated-units", $target-skeleton-uri, document {$xliff-skeleton}) --- Creates the expected files in the expected location :)
(: concat($target-uri, ' --- ', $target-skeleton-uri) --- remove decl as updating function to test this, both paths are set :)