Skip to content

Commit

Permalink
add XQuery test to check for missing entries in language files (#454)
Browse files Browse the repository at this point in the history
* 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
peterstadler and bwbohl authored Nov 8, 2024
1 parent a27c830 commit f807267
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 27 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -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
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ When you have your system prepared with all Sencha Cmd prerequisites or you have

Edirom Online depends heavily on the JavaScript framework [Ext JS] which is included in parts in our code base. We use Ext JS 4.2.1 in the GPL version. Edirom Online also includes the [Raphaël] javascript library (MIT License) and the [ACE] editor (BSD license).

For running the tests provided in the [ANT build file] we rely on `xmllint`
and `SaxonHE`.
On a Debian based Linux system these can be installed with `apt-get install
libsaxonhe-java libxml2-utils`.
If SaxonHE is not available from your classpath by default you might need to
explicitly point ANT at it by providing the `-lib` parameter, e.g. `ant -lib
/usr/share/java/ run-all-tests`.


## Roadmap

Until today Edirom-Online and its features were developed as one application with strong dependencies on the JavaScript framework [Ext JS] (current version Ext JS 4.2.1) like mentioned above. Frontend and backend are currently living in this one application. Regarding to Edirom-Onlines release plans ExtJS is planned to be updated in the near future until ExtJS 7.0.0.
Expand Down Expand Up @@ -162,7 +171,7 @@ Edirom Online is released to the public under the terms of the [GNU GPL v.3] ope
[GitHub Discussions]: https://github.com/Edirom/Edirom-Online/discussions
[Contributor Code of Conduct]: CODE_OF_CONDUCT.md
[GNU GPL v.3]: http://www.gnu.org/copyleft/gpl.html

[ANT build file]: https://github.com/Edirom/Edirom-Online/blob/develop/build.xml

<!--
# EdiromOnline/app
Expand Down
1 change: 1 addition & 0 deletions add/data/locale/edirom-lang-de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
<entry key="view.window.source.SourceView_MeasureBasedView_previousMeasure" value="Vorheriger Takt"/>
<entry key="view.window.source.SourceView_MeasureBasedView_measureSpinner" value="Taktauswahl" />
<entry key="view.window.source.SourceView_MeasureBasedView_nextMeasure" value="Nächster Takt"/>
<entry key="view.window.source.SourceView_MeasureBasedView_movementSelectorBox" value="Auswahl von Satz/Nummer"/>
<entry key="view.window.source.SourceView_MeasureBasedView_selectVoices" value="Stimmenauswahl"/>
<entry key="view.window.text.TextView_annotMenu" value="Anmerkungen"/>
<entry key="view.window.text.TextView_showAnnotations" value="Anmerkungen ein-/ausblenden"/>
Expand Down
14 changes: 5 additions & 9 deletions add/data/xslt/i18n/de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<entry xml:id="pbl">Herausgeber</entry>
<entry xml:id="pdr">Project director</entry>
<entry xml:id="rce">Tontechnik</entry>
<entry xml:id="rth">Research tem head</entry>
<entry xml:id="rth">Research team head</entry>
<entry xml:id="scr">Schreiber</entry>
<entry xml:id="spn">Sponsor</entry>
<!-- Identifier Klassen -->
Expand Down Expand Up @@ -109,9 +109,6 @@
<entry xml:id="componentGrp">Bestandteile</entry>
<entry xml:id="expressionList">Expressionen</entry>
<entry xml:id="handList">Schreiber</entry>
<entry xml:id="pubStmt">Publikation</entry>
<entry xml:id="pupPlace">Ort</entry>


<entry xml:id="corpName">Körperschaft</entry>
<entry xml:id="captureMode">Aufnahmemodus</entry>
Expand All @@ -123,6 +120,8 @@

<!-- MEI & TEI -->
<entry xml:id="ptr">Link</entry>
<entry xml:id="pubPlace">Ort der Veröffentlichung</entry>
<entry xml:id="pubStmt">Informationen zur Publikation</entry>

<!-- TEI -->
<entry xml:id="abstract">Editorische Zusammenfassung</entry>
Expand All @@ -142,7 +141,6 @@
<entry xml:id="msIdentifier">Repositorium</entry>
<entry xml:id="orgName">Organisation</entry>
<entry xml:id="publicationStmt">Publikation</entry>
<entry xml:id="profileDesc">Nicht-bibliographische Aspekte</entry>
<entry xml:id="seriesStmt">Reihe</entry>
<entry xml:id="title_a">Titel (analytisch)</entry>
<entry xml:id="title_m">Titel (monographisch)</entry>
Expand All @@ -158,9 +156,8 @@
<entry xml:id="handNotes">Schreiber-Anmerkungen</entry>
<entry xml:id="itemList">Exemplar(e)</entry>
<entry xml:id="placeName">Ort</entry>
<entry xml:id="pubStmt">Informationen zur Publikation</entry>

<entry xml:id="respStmt">Verantwortlich</entry>
<entry xml:id="pubPlace">Ort der Veröffentlichung</entry>
<entry xml:id="profileDesc">Nicht-bibliographische Angaben</entry>


Expand All @@ -183,7 +180,6 @@
<entry xml:id="width">Breite</entry>
<entry xml:id="height">Höhe</entry>
<entry xml:id="descLink">Quellenbeschreibung</entry>

<entry xml:id="singers">Sänger</entry>
<entry xml:id="singers">Sänger</entry>
<entry xml:id="musicians">Musiker</entry>
</language>
59 changes: 49 additions & 10 deletions add/data/xslt/i18n/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,27 @@
<entry xml:id="titleStmt">Title Statement</entry>
<!-- marc keys : http://www.loc.gov/marc/relators/relaterm.html -->
<entry xml:id="cmp">Composer</entry>
<entry xml:id="cnd">Conductor</entry>
<entry xml:id="csl">Consultant</entry>
<entry xml:id="dst">Distributor</entry>
<entry xml:id="dtc">Data contributor</entry>
<entry xml:id="edt">Editor</entry>
<entry xml:id="fnd">Funder</entry>
<entry xml:id="led">Lead</entry>
<entry xml:id="mcp">Music copyist</entry>
<entry xml:id="mus">Musiker</entry>
<entry xml:id="mrk">Markup Editor</entry>
<entry xml:id="pbd">Verlagsleiter</entry>
<entry xml:id="pbl">Herausgeber</entry>
<entry xml:id="pdr">Project director</entry>
<entry xml:id="rce">Tontechnik</entry>
<entry xml:id="rth">Research team head</entry>
<entry xml:id="scr">Scribe</entry>
<entry xml:id="spn">Sponsor</entry>
<!-- Identifier Klassen -->
<entry xml:id="labelCode">Labelcode</entry>
<entry xml:id="orderNo">Order number</entry>
<entry xml:id="EAN">Article number (EAN)</entry>
<!-- Titelei -->
<entry xml:id="publication">Publikation</entry>
<entry xml:id="series">Series</entry>
Expand Down Expand Up @@ -86,12 +105,25 @@
<entry xml:id="unpub">Unpublished</entry>
<entry xml:id="geogName">Place</entry>
<!-- MEI -->
<entry xml:id="annot">Annotation</entry>
<entry xml:id="componentGrp">Components</entry>
<entry xml:id="expressionList">Expressions</entry>
<entry xml:id="handList">Scribes</entry>
<entry xml:id="puStmt">Publication</entry>
<entry xml:id="puPlace">Place</entry>



<entry xml:id="corpName">Corporation name</entry>
<entry xml:id="captureMode">Capturing mode</entry>
<entry xml:id="carrierForm">Carrier form</entry>
<entry xml:id="fileChar">File characteristics</entry>
<entry xml:id="playingSpeed">Playing speed</entry>
<entry xml:id="relationList">FRBR-relations</entry>
<entry xml:id="soundChan">Sound channels</entry>

<!-- MEI & TEI -->
<entry xml:id="ptr">Link</entry>
<entry xml:id="pubPlace">Publication Place</entry>
<entry xml:id="pubStmt">Publication Statement</entry>
<!-- TEI -->
<entry xml:id="abstract">Abstract</entry>
<entry xml:id="additional">Additional information</entry>
<entry xml:id="additions">Additions</entry>
<entry xml:id="availability">Availability</entry>
Expand All @@ -106,8 +138,8 @@
<entry xml:id="material">Material</entry>
<entry xml:id="msName">Manuscript name</entry>
<entry xml:id="msIdentifier">Location</entry>
<entry xml:id="orgName">Organisation</entry>
<entry xml:id="publicationStmt">Publication</entry>
<entry xml:id="profileDesc">Non-bibliographic aspects</entry>
<entry xml:id="seriesStmt">Series</entry>
<entry xml:id="title_a">Title (analytic)</entry>
<entry xml:id="title_m">Title (monographic)</entry>
Expand All @@ -120,25 +152,32 @@
<entry xml:id="settlement">Settlement</entry>
<entry xml:id="supportDesc">Support Description</entry>
<entry xml:id="handDesc">Description of Hands</entry>
<entry xml:id="handNotes">Notes on hands</entry>
<entry xml:id="itemList">Item List</entry>
<entry xml:id="pubStmt">Publication Statement</entry>
<entry xml:id="placeName">Place name</entry>

<entry xml:id="respStmt">Responsibility</entry>
<entry xml:id="pubPlace">Publication Place</entry>
<entry xml:id="profileDesc">Non-bibliographic aspects</entry>

<entry xml:id="Encoders">Encoders</entry>
<entry xml:id="binding">Binding</entry>
<entry xml:id="leavesCount">(leaves)</entry>
<entry xml:id="leavesCount">(leaves)</entry>
<entry xml:id="manuscript">manuscript</entry>
<entry xml:id="imprint_publisher">Publisher</entry>
<entry xml:id="analytic">Work</entry>
<entry xml:id="monogr">Publication</entry>

<entry xml:id="leaf">leaf</entry>
<entry xml:id="cm">cm</entry>


<entry xml:id="title_desc">Descriptive title</entry>
<entry xml:id="title_main">Main title</entry>
<entry xml:id="title_sub">Subordinate title</entry>

<!-- FreiDi /content -->
<entry xml:id="width">width</entry>
<entry xml:id="height">height</entry>
<entry xml:id="descLink">Source Description</entry>
</language>
<entry xml:id="singers">Singers</entry>
<entry xml:id="musicians">Musicians</entry>
</language>
44 changes: 42 additions & 2 deletions testing/ant-tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<property name="xqunit-url" value="http://localhost:8080/exist/apps/Edirom-Online/testing/XQSuite/run-unit-tests.xq"/>

<target name="run-all-tests" depends="xqunit-tests"/>
<target name="run-all-tests" depends="xqunit-tests,check-language-files"/>

<target name="-check-dependencies">
<description>Check for necessary executables</description>
Expand Down Expand Up @@ -48,5 +48,45 @@
</condition>
</fail>
</target>


<target name="check-language-files">
<description>Check alignment of language files and report missing entries</description>
<parallel>
<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/locale?select=*.xml"/>
</java>
<fail>
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
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>
<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>
</parallel>
</target>

</project>
69 changes: 69 additions & 0 deletions testing/check-language-files.xq
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>

0 comments on commit f807267

Please sign in to comment.