Commit 3952576b authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

i18n fix

parent 0f5fe535
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
/content_html
/templates
/autoroute
/locales
/package
.max
.idea
+2 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ demo: ## Installation d'une édition de démo
		cp -r .max/fixtures/templates .;\
		cp -r .max/fixtures/autoroute .;\
		cp -r .max/fixtures/config.xml .;\
		cp -r .max/fixtures/locales .;\
		echo 'demo installée.';\
	fi
.PHONY: demo
@@ -106,6 +107,7 @@ clean: ## Supprime l'installation de MaX et les fichiers du projet
		rm -rf content_html;\
		rm -rf templates;\
		rm -rf autoroute;\
		rm -rf locales;\
		rm config.xml;\
		rm -rf .max;\
    else\
+3 −0
Original line number Diff line number Diff line
{
    "tdm": "Sommaire"
}
 No newline at end of file
+4 −2
Original line number Diff line number Diff line
@@ -15,7 +15,8 @@ import module namespace utils = 'https://certic.unicaen.fr/max/utils' at 'utils.
declare function i18n:translate ($key as xs:string, $lang as xs:string) as xs:string {
   try {
    let $translations := json:doc(i18n:getUserLocalesPath() || $lang || '.json')
    return string(($translations/json/*[local-name(.)=$key])[1]/text())
    let $translation := string(($translations/json/*[local-name(.)=$key])[1]/text())
    return if($translation = '') then i18n:default-translate($key, $lang) else $translation
   }catch * {i18n:default-translate($key, $lang)}
};

@@ -28,7 +29,8 @@ declare function i18n:translate ($key as xs:string, $lang as xs:string) as xs:st
declare function i18n:default-translate ($key as xs:string, $lang as xs:string) as xs:string {
   try {
    let $translations := json:doc(i18n:getVocabularyLocalesPath()  || $lang || '.json')
    return string(($translations/json/*[local-name(.)=$key])[1]/text())
    let $translation := string(($translations/json/*[local-name(.)=$key])[1]/text())
    return if($translation = '') then $key else $translation
   }catch * {$key}
};