-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add XQuery test to check for missing entries in language files (#454)
* add xquery to check for missing entries in language files * add new check to ant build file * some cleanup * add new test to GIthub actions * add dependency * Install libsaxonhe-java for XQuery support * add lib parameter to ant call with path to Saxon-HE.jar, see https://packages.ubuntu.com/focal/all/libsaxonhe-java/filelist * add missing entry to German language file which already exists in the English version * add information about dependencies for running tests * fix typo * remove duplicate xml:ids * add support for language files at `/add/data/xslt/i18n` * aligning i18n langfiles * explicitly check for duplicate keys * Update add/data/xslt/i18n/en.xml Co-authored-by: Benjamin W. Bohl <[email protected]> * Update add/data/xslt/i18n/en.xml Co-authored-by: Benjamin W. Bohl <[email protected]> * translate term * fix grouping key for i18n files Co-authored-by: Benjamin W. Bohl <[email protected]> * run tests in parallel Co-authored-by: Benjamin W. Bohl <[email protected]> * be very specific about data types * minor code linting --------- Co-authored-by: bwbohl <[email protected]>
- Loading branch information
1 parent
a27c830
commit f807267
Showing
7 changed files
with
192 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,20 @@ jobs: | |
# saving this as output for following jobs to pick up | ||
artifact_name: EdiromOnline_${{ steps.short-sha.outputs.sha }}.zip | ||
|
||
check-language-files: | ||
name: Check alignment of language files | ||
needs: build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Install libsaxonhe-java for XQuery support | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install libsaxonhe-java | ||
- name: Run test | ||
run: ant -lib /usr/share/java/ check-language-files | ||
|
||
xqunit: | ||
name: Run XQSuite unit tests | ||
|
@@ -66,8 +80,6 @@ jobs: | |
with: | ||
name: ${{ needs.build.outputs.artifact_name }} | ||
path: xars | ||
- name: debug | ||
run: ls -laR ${{ github.workspace }} | ||
- name: Create Docker container | ||
run: | | ||
docker create --rm --name edirom-online -p 8080:8080 stadlerpeter/existdb:6 | ||
|
@@ -84,7 +96,8 @@ jobs: | |
|
||
update-tag: | ||
name: Update git development tag and Github release | ||
needs: [build,xqunit] | ||
needs: [build,xqunit,check-language-files] | ||
if: ${{ github.event_name == 'push' && github.ref_name == 'develop' }} | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
@@ -93,7 +106,6 @@ jobs: | |
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Delete dev-release | ||
if: ${{ github.event_name == 'push' && github.ref_name == 'develop' }} | ||
run: gh release delete dev --cleanup-tag -y | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
@@ -106,7 +118,6 @@ jobs: | |
path: xars | ||
|
||
- name: Create dev-release | ||
if: ${{ github.event_name == 'push' && github.ref_name == 'develop' }} | ||
uses: ncipollo/[email protected] | ||
with: | ||
allowUpdates: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
xquery version "3.1"; | ||
|
||
(:~ | ||
: XQuery for checking that contents of language files are aligned | ||
:) | ||
|
||
|
||
(: NAMESPACE DECLARATIONS ================================================== :) | ||
|
||
declare namespace edirom="http://www.edirom.de/ns/1.3"; | ||
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; | ||
|
||
(: OPTION DECLARATIONS ===================================================== :) | ||
|
||
declare option output:media-type "application/xml"; | ||
declare option output:method "xml"; | ||
declare option output:indent "yes"; | ||
declare option output:omit-xml-declaration "yes"; | ||
|
||
(: VARIABLE DECLARATIONS =================================================== :) | ||
|
||
declare variable $edirom:language-files-path as xs:string external; | ||
|
||
(: FUNCTION DECLARATIONS =================================================== :) | ||
|
||
declare function edirom:print-missing-keys() as element()* { | ||
|
||
let $language-files as document-node()* := collection($edirom:language-files-path) | ||
|
||
let $languages as xs:string* := | ||
( | ||
$language-files/langFile/lang | (: language files in add/data/locale :) | ||
$language-files/language/@xml:lang (: language files in add/data/xslt/i18n :) | ||
) ! string(.) | ||
|
||
return | ||
|
||
for $entry in $language-files//entry | ||
group by $key := $entry/data((@key,@xml:id)) | ||
where count($entry) ne count($language-files) | ||
|
||
let $available as xs:string+ := | ||
( | ||
$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 as xs:string* := $languages[not(. = $available)] | ||
|
||
let $duplicates as xs:string* := | ||
for $i in $entry | ||
group by $langkey := data(($i/ancestor::langFile/lang, $i/parent::language/@xml:lang)) | ||
where count($i) gt 1 | ||
return $langkey => string() | ||
|
||
return | ||
if(count($duplicates) gt 0) then | ||
(: duplicate keys :) | ||
<key duplicates="{$duplicates => string-join(' ')}">{$key}</key> | ||
else | ||
(: missing keys :) | ||
<key missing="{$missing => string-join(' ')}" available="{$available => string-join(' ')}">{$key}</key> | ||
}; | ||
|
||
(: QUERY BODY ============================================================== :) | ||
|
||
<results>{ | ||
edirom:print-missing-keys() | ||
}</results> |