Skip to content

Commit

Permalink
add support for language files at /add/data/xslt/i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstadler committed Nov 6, 2024
1 parent f0dda3b commit 3f446d2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
19 changes: 18 additions & 1 deletion testing/ant-tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<arg value="{http://www.edirom.de/ns/1.3}language-files-path=../add/data/locale?select=*.xml"/>
</java>
<fail>
Missing entries in language files: &#10;${xquery.result}
Missing entries in language files at /add/data/locale: &#10;${xquery.result}
<condition>
<!--
If all goes well, "<results/>" will be returned of string-length=10
Expand All @@ -68,6 +68,23 @@
</condition>
</fail>
</sequential>
<sequential>
<local name="xquery.result"/>
<java classname="net.sf.saxon.Query" failonerror="false" outputproperty="xquery.result">
<arg value="testing/check-language-files.xq"/>
<arg value="{http://www.edirom.de/ns/1.3}language-files-path=../add/data/xslt/i18n?select=*.xml"/>
</java>
<fail>
Missing entries in language files at /add/data/xslt/i18n: &#10;${xquery.result}
<condition>
<!--
If all goes well, "<results/>" will be returned of string-length=10
Any errors reported will add to this string-length hence cause the test to fail
-->
<length string="${xquery.result}" when="greater" length="10"/>
</condition>
</fail>
</sequential>
</target>

</project>
12 changes: 9 additions & 3 deletions testing/check-language-files.xq
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@ declare variable $edirom:language-files-path as xs:string external;

declare function edirom:print-missing-keys() as element()* {
let $language-files := collection($edirom:language-files-path)
let $languages := $language-files/langFile/lang
let $languages :=
$language-files/langFile/lang | (: language files in add/data/locale :)
$language-files/language/@xml:lang (: language files in add/data/xslt/i18n :)
return

for $entry in $language-files//entry
group by $key := $entry/data(@key)
group by $key := $entry/data((@key,@xml:id))
where count($entry) ne count($language-files)
let $available := $entry/ancestor::langFile/lang ! string(.)
let $available :=
(
$entry/ancestor::langFile/lang ! string(.), (: language files in add/data/locale :)
$entry/parent::language/@xml:lang ! string(.) (: language files in add/data/xslt/i18n :)
)
let $missing := $languages[not(. = $available)]
return
<key missing="{$missing => string-join(' ')}" available="{$available => string-join(' ')}">{$key}</key>
Expand Down

0 comments on commit 3f446d2

Please sign in to comment.