From 62d40b09f2a25c9d935cd120594bd36534f4c360 Mon Sep 17 00:00:00 2001 From: Alexander Nguyen Date: Thu, 12 Dec 2024 16:11:34 +0100 Subject: [PATCH] Support for localized disclaimers #34 --- add/data/xql/getMeasures.xql | 7 ++++--- add/data/xql/getPages.xql | 3 ++- app/controller/window/source/MeasureBasedView.js | 3 ++- app/controller/window/source/PageBasedView.js | 3 ++- app/controller/window/text/FacsimileView.js | 3 ++- app/controller/window/text/TextFacsimileSplitView.js | 3 ++- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/add/data/xql/getMeasures.xql b/add/data/xql/getMeasures.xql index 1d49b5f2a..f349fd9d8 100644 --- a/add/data/xql/getMeasures.xql +++ b/add/data/xql/getMeasures.xql @@ -30,9 +30,9 @@ import module namespace console="http://exist-db.org/xquery/console"; declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; -declare function local:getMeasures($mei as node(), $mdivID as xs:string) as xs:string* { +declare function local:getMeasures($mei as node(), $mdivID as xs:string, $lang as xs:string) as xs:string* { - let $disclaimer := $mei//mei:pubStmt//mei:useRestrict[@type = 'disclaimer']/string() => replace('\n', '
') + let $disclaimer := $mei//mei:pubStmt//mei:useRestrict[@type = 'disclaimer'][if (./@xml:lang) then (./@xml:lang = $lang) else (.)]/string() => replace('\n', '
') return if($mei//mei:parts) then( @@ -110,8 +110,9 @@ declare function local:getMeasures($mei as node(), $mdivID as xs:string) as xs:s let $uri := request:get-parameter('uri', '') let $mdivID := request:get-parameter('mdiv', '') +let $lang := request:get-parameter('lang', 'en') let $mei := doc($uri)/root() -let $ret := local:getMeasures($mei, $mdivID) +let $ret := local:getMeasures($mei, $mdivID, $lang) return concat('[', string-join($ret, ','), ']') \ No newline at end of file diff --git a/add/data/xql/getPages.xql b/add/data/xql/getPages.xql index 64acefa78..302fae175 100644 --- a/add/data/xql/getPages.xql +++ b/add/data/xql/getPages.xql @@ -32,9 +32,10 @@ declare namespace xmldb="http://exist-db.org/xquery/xmldb"; declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; let $uri := request:get-parameter('uri', '') +let $lang := request:get-parameter('lang', 'en') let $mei := eutil:getDoc($uri)/root() -let $disclaimer := $mei//mei:pubStmt//mei:useRestrict[@type = 'disclaimer']/string() => replace('\n', '
') +let $disclaimer := $mei//mei:pubStmt//mei:useRestrict[@type = 'disclaimer'][if (./@xml:lang) then (./@xml:lang = $lang) else (.)]/string() => replace('\n', '
') let $ret := for $surface in $mei//mei:surface (:let $image := doc($surface/mei:graphic[@type='facsimile']/string(@target))/img:image:) diff --git a/app/controller/window/source/MeasureBasedView.js b/app/controller/window/source/MeasureBasedView.js index 0c65dc7f5..57b69728c 100644 --- a/app/controller/window/source/MeasureBasedView.js +++ b/app/controller/window/source/MeasureBasedView.js @@ -72,7 +72,8 @@ Ext.define('EdiromOnline.controller.window.source.MeasureBasedView', { method: 'GET', params: { uri: view.owner.uri, - mdiv: mdiv + mdiv: mdiv, + lang: getPreference('application_language') }, success: function(response){ var data = response.responseText; diff --git a/app/controller/window/source/PageBasedView.js b/app/controller/window/source/PageBasedView.js index aba59aa52..8cc60c942 100644 --- a/app/controller/window/source/PageBasedView.js +++ b/app/controller/window/source/PageBasedView.js @@ -44,7 +44,8 @@ Ext.define('EdiromOnline.controller.window.source.PageBasedView', { url: 'data/xql/getPages.xql', method: 'GET', params: { - uri: view.owner.uri + uri: view.owner.uri, + lang: getPreference('application_language') }, success: function(response){ var data = response.responseText; diff --git a/app/controller/window/text/FacsimileView.js b/app/controller/window/text/FacsimileView.js index b15bb7a47..74b986ed0 100644 --- a/app/controller/window/text/FacsimileView.js +++ b/app/controller/window/text/FacsimileView.js @@ -48,7 +48,8 @@ Ext.define('EdiromOnline.controller.window.text.FacsimileView', { url: 'data/xql/getPages.xql', method: 'GET', params: { - uri: uri + uri: uri, + lang: getPreference('application_language') }, success: function(response){ var data = response.responseText; diff --git a/app/controller/window/text/TextFacsimileSplitView.js b/app/controller/window/text/TextFacsimileSplitView.js index 3d0dd9683..6e39e8137 100644 --- a/app/controller/window/text/TextFacsimileSplitView.js +++ b/app/controller/window/text/TextFacsimileSplitView.js @@ -54,7 +54,8 @@ Ext.define('EdiromOnline.controller.window.text.TextFacsimileSplitView', { url: 'data/xql/getPages.xql', method: 'GET', params: { - uri: uri + uri: uri, + lang: getPreference('application_language') }, success: function(response){ var data = response.responseText;