Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
pdn-certic
MaX
Commits
02b3a8ae
Commit
02b3a8ae
authored
Mar 30, 2022
by
Jerome Chauveau
Browse files
Possibilité de modifier la langue par défaut : attribut lang sur le root node <edition/>.
#137
parent
055d75ff
Changes
2
Hide whitespace changes
Inline
Side-by-side
rxq/config.xqm
View file @
02b3a8ae
...
...
@@ -42,6 +42,16 @@ declare function max.config:getProjectPrettyName($projectId){
else $projectId
};
(:returns edition prettyName from config file:)
declare function max.config:getProjectDefaultLang($projectId){
let $lang := doc($max.config:CONFIGURATION_FILE)//edition[@xml:id=$projectId]/@lang
return
if($lang)
then string($lang)
else 'fr'
};
(:returns enabled plugin name list:)
declare function max.config:getEnabledPluginNames($projectId){
doc($max.config:CONFIGURATION_FILE)//edition[@xml:id=$projectId]//plugin/@name
...
...
rxq/i18n.xqm
View file @
02b3a8ae
...
...
@@ -2,7 +2,7 @@
module namespace max.i18n = 'pddn/max/i18n';
import module namespace max.util = 'pddn/max/util' at 'util.xqm';
import module namespace max.config = 'pddn/max/config' at 'config.xqm';
declare
%rest:GET
...
...
@@ -12,12 +12,12 @@ function max.i18n:setLang($projectId, $lang){
};
declare function max.i18n:getLang($projectId){
session:get($projectId || '-lang',
'fr'
)
session:get($projectId || '-lang',
max.config:getProjectDefaultLang($projectId)
)
};
declare function max.i18n:getText($projectId as xs:string, $key as xs:string){
max.i18n:getText($projectId, $key, session:get($projectId || '-lang',
'fr'
))
max.i18n:getText($projectId, $key, session:get($projectId || '-lang',
max.config:getProjectDefaultLang($projectId)
))
};
declare function max.i18n:getText($projectId as xs:string, $key as xs:string, $locale as xs:string ?)
...
...
@@ -49,72 +49,3 @@ declare function max.i18n:getLanguageList($projectId){
}
catch * {'fr'}
};
(:
declare function max.i18n:getMap($projectId, $locale){
let $i18nResourceFile := max.util:maxHome() || "/ui/i18n/I18n" || $locale || ".xml"
let $projectI18nFile := max.util:maxHome() || "/editions/" || $projectId || "/ui/i18n/I18n" || $locale || ".xml"
let $primaryI18n := if (file:exists($projectI18nFile)) then doc($projectI18nFile) else doc($i18nResourceFile)
let $secondaryI18n := if (file:exists($projectI18nFile)) then doc($i18nResourceFile) else ()
let $m1 := map:merge(
for $entry in $primaryI18n//entry
return map {string($entry/@key) : $entry/text()
}
)
let $m2 := map:merge(
for $entry in $secondaryI18n//entry
return
if(not($primaryI18n//entry[@key=$entry/@key]))
then map {string($entry/@key) : $entry/text()}
else()
)
return map:merge(($m2,$m1))
};
:)
(:
declare function max.i18n:getI18n($projectId, $locale) as node()*{
let $i18nResourceFile := max.util:maxHome() || "/ui/i18n/I18n" || $locale || ".xml"
let $projectI18nFile := max.util:maxHome() || "/editions/" || $projectId || "/ui/i18n/I18n" || $locale || ".xml"
let $primaryI18n := if (file:exists($projectI18nFile)) then doc($projectI18nFile) else doc($i18nResourceFile)
let $secondaryI18n := if (file:exists($projectI18nFile)) then doc($i18nResourceFile) else ()
return
<entries>
{
for $entry in $primaryI18n//entry
return $entry
}
{
for $entry in $secondaryI18n//entry
return
if(not($primaryI18n//entry[@key=$entry/@key]))
then $entry
else()
}
</entries>
};
declare
%rest:GET
%output:method("html")
%output:html-version("5.0")
%output:indent("no")
%output:encoding("UTF-8")
%rest:path( "/{$projectId}/i18n/{$locale}.html")
function max.i18n:listPage($projectId, $locale){
let $map := max.i18n:getMap($projectId, $locale)
return
<html>
<body>
<h1>
I18n - {$projectId} - {$locale}
</h1>
<ul>
{
for $k in map:keys($map)
return
<li>
{$k} : {map:get($map, $k)}
</li>
}
</ul>
</body>
</html>
};
:)
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment