From f807267c1e2b45c990f9de55acbae8b60a6cb5b0 Mon Sep 17 00:00:00 2001 From: Peter Stadler Date: Fri, 8 Nov 2024 16:49:37 +0100 Subject: [PATCH] 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 * Update add/data/xslt/i18n/en.xml Co-authored-by: Benjamin W. Bohl * translate term * fix grouping key for i18n files Co-authored-by: Benjamin W. Bohl * run tests in parallel Co-authored-by: Benjamin W. Bohl * be very specific about data types * minor code linting --------- Co-authored-by: bwbohl --- .github/workflows/pre-release.yml | 21 ++++++--- README.md | 11 ++++- add/data/locale/edirom-lang-de.xml | 1 + add/data/xslt/i18n/de.xml | 14 +++--- add/data/xslt/i18n/en.xml | 59 ++++++++++++++++++++----- testing/ant-tests.xml | 44 ++++++++++++++++++- testing/check-language-files.xq | 69 ++++++++++++++++++++++++++++++ 7 files changed, 192 insertions(+), 27 deletions(-) create mode 100644 testing/check-language-files.xq diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index d22a5ba2e..42c3d7831 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -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/release-action@v1.14.0 with: allowUpdates: true diff --git a/README.md b/README.md index 2ff9c551c..bc77d6c54 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 @@ -109,9 +109,6 @@ Bestandteile Expressionen Schreiber - Publikation - Ort - Körperschaft Aufnahmemodus @@ -123,6 +120,8 @@ Link + Ort der Veröffentlichung + Informationen zur Publikation Editorische Zusammenfassung @@ -142,7 +141,6 @@ Repositorium Organisation Publikation - Nicht-bibliographische Aspekte Reihe Titel (analytisch) Titel (monographisch) @@ -158,9 +156,8 @@ Schreiber-Anmerkungen Exemplar(e) Ort - Informationen zur Publikation + Verantwortlich - Ort der Veröffentlichung Nicht-bibliographische Angaben @@ -183,7 +180,6 @@ Breite Höhe Quellenbeschreibung - -Sänger + Sänger Musiker \ No newline at end of file diff --git a/add/data/xslt/i18n/en.xml b/add/data/xslt/i18n/en.xml index 6d1a57111..308ed1a2a 100644 --- a/add/data/xslt/i18n/en.xml +++ b/add/data/xslt/i18n/en.xml @@ -6,8 +6,27 @@ Title Statement Composer + Conductor + Consultant + Distributor + Data contributor + Editor + Funder + Lead Music copyist + Musiker + Markup Editor + Verlagsleiter + Herausgeber + Project director + Tontechnik + Research team head Scribe + Sponsor + + Labelcode + Order number + Article number (EAN) Publikation Series @@ -86,12 +105,25 @@ Unpublished Place + Annotation + Components + Expressions Scribes - Publication - Place - - + + Corporation name + Capturing mode + Carrier form + File characteristics + Playing speed + FRBR-relations + Sound channels + + + Link + Publication Place + Publication Statement + Abstract Additional information Additions Availability @@ -106,8 +138,8 @@ Material Manuscript name Location + Organisation Publication - Non-bibliographic aspects Series Title (analytic) Title (monographic) @@ -120,15 +152,16 @@ Settlement Support Description Description of Hands + Notes on hands Item List - Publication Statement + Place name + Responsibility - Publication Place Non-bibliographic aspects Encoders Binding - (leaves) + (leaves) manuscript Publisher Work @@ -136,9 +169,15 @@ leaf cm - + + Descriptive title + Main title + Subordinate title + width height Source Description - \ No newline at end of file + Singers + Musicians + diff --git a/testing/ant-tests.xml b/testing/ant-tests.xml index 1d619be30..2a67eabdd 100644 --- a/testing/ant-tests.xml +++ b/testing/ant-tests.xml @@ -3,7 +3,7 @@ - + Check for necessary executables @@ -48,5 +48,45 @@ - + + + Check alignment of language files and report missing entries + + + + + + + + + Missing entries in language files at /add/data/locale: ${xquery.result} + + + + + + + + + + + + + + Missing entries in language files at /add/data/xslt/i18n: ${xquery.result} + + + + + + + + + diff --git a/testing/check-language-files.xq b/testing/check-language-files.xq new file mode 100644 index 000000000..07079da09 --- /dev/null +++ b/testing/check-language-files.xq @@ -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} + else + (: missing keys :) + {$key} +}; + +(: QUERY BODY ============================================================== :) + +{ + edirom:print-missing-keys() +}