Skip to content

Instantly share code, notes, and snippets.

@tuurma
Last active July 8, 2020 20:26
Show Gist options
  • Save tuurma/e46eedf6d045cb3c1afa9cf03150ba62 to your computer and use it in GitHub Desktop.
Save tuurma/e46eedf6d045cb3c1afa9cf03150ba62 to your computer and use it in GitHub Desktop.
synchronise Crowdin language files to pb-components
xquery version "3.1";
(:Bulgarian, Czech, Dutch, French, German, Greek, Italian, Norwegian, Polish, Portuguese, Romanian, Slovenian, Spanish, Swedish, Turkish, Ukrainian, Russian, Georgian:)
(:Cymru, Finnish, Hebrew, Hungarian, Japan:)
let $collection := '/db/apps/lang'
let $temp-target := '/db/apps/i18n/temp'
let $final-target := '/db/apps/i18n/common'
let $languages := ('bg', 'cs', 'nl', 'fr', 'de', 'el', 'it', 'no', 'pl', 'pt', 'ro', 'sl', 'es', 'sv', 'tr', 'uk', 'cy', 'fi', 'he', 'hu', 'ja', 'zh_CN', 'zh_TW', 'ka', 'ru')
return
(
for $child in xmldb:get-child-collections($collection)
let $path := concat($collection, '/', $child)
for $file in xmldb:get-child-resources($path)
return
xmldb:copy-resource($path, $file, $temp-target, $file)
,
for $lang in $languages
let $file := xmldb:get-child-resources($temp-target)[starts-with(., $lang)]
return
xmldb:copy-resource($temp-target, $file, $final-target, $lang || '.json')
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment