Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/441 Fail if no language is set #461

Merged
merged 15 commits into from
Dec 10, 2024
Merged
2 changes: 1 addition & 1 deletion add/controller.xql
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ return
(: forward index.html to index.xql :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="index.xql">
<set-header name="Set-Cookie" value="edirom-language={$langVal}" />
riedde marked this conversation as resolved.
Show resolved Hide resolved
<add-parameter name="lang" value="{$langVal}"/>
<add-parameter name="exist:controller" value="{$exist:controller}"/>
riedde marked this conversation as resolved.
Show resolved Hide resolved
</forward>
</dispatch>
(:else if (starts-with($exist:path, "/data")) then
Expand Down
2 changes: 1 addition & 1 deletion add/data/xqm/edition.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ declare namespace xlink = "http://www.w3.org/1999/xlink";

(: VARIABLE DECLARATIONS =================================================== :)

declare variable $edition:default-prefs-location as xs:string := '../prefs/edirom-prefs.xml';
declare variable $edition:default-prefs-location as xs:string := request:get-parameter('exist:controller','xmldb:exist:///db/apps/Edirom-Online') || '/data/prefs/edirom-prefs.xml';
roewenstrunk marked this conversation as resolved.
Show resolved Hide resolved

(: FUNCTION DECLARATIONS =================================================== :)

Expand Down
19 changes: 10 additions & 9 deletions add/data/xqm/util.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,19 @@ declare function eutil:getLanguageString($key as xs:string, $values as xs:string
:)
declare function eutil:getPreference($key as xs:string, $edition as xs:string?) as xs:string {
riedde marked this conversation as resolved.
Show resolved Hide resolved

let $preferencesFile :=
let $prefFileCustom :=
try { doc(edition:getPreferencesURI($edition)) }
catch * { util:log-system-out('Failed to load preferences') }


let $prefFileDefault := doc($edition:default-prefs-location)
riedde marked this conversation as resolved.
Show resolved Hide resolved

let $prefFile := if($prefFileCustom//entry/@key = $key) then
$prefFileCustom
else
($prefFileDefault)

return
$preferencesFile//entry[@key = $key]/@value => string()
$prefFile//entry[@key = $key]/@value => string()
riedde marked this conversation as resolved.
Show resolved Hide resolved

};

Expand All @@ -303,16 +310,10 @@ declare function eutil:getPreference($key as xs:string, $edition as xs:string?)
: @return The language key
:)
declare function eutil:getLanguage($edition as xs:string?) as xs:string {
riedde marked this conversation as resolved.
Show resolved Hide resolved

if (request:get-parameter("lang", "") != "") then
request:get-parameter("lang", "")

else if(request:get-cookie-names() = 'edirom-language') then
request:get-cookie-value('edirom-language')

else
eutil:getPreference('application_language', edition:findEdition($edition))

};

(:~
Expand Down