/* localisation 1.0 - 99-09-08 S.Huet */ var defaultLanguage="english";; var prevLanguage="english";; typeof currentLanguage = S;; typeof tabloc = tab [[S S] r1];; fun cmpbyclear(x,y)= let x->[_ a] in let y->[_ b] in strcmp a b;; fun getInfos(l,a)= if l==nil then nil else let l->[q nxt] in if !strcmp hd q a then tl q else getInfos nxt a;; fun buildl(l, bpath)= if l==nil then nil else let l->[a n] in let buildl n bpath -> res in if (!strcmp substr a 0 (strlen bpath) bpath)&&(!strcmp substr a (strlen a)-5 5 ".lang") then let hd getInfos strextr _getpack _checkpack a "LANGUAGE" -> s in if s==nil then res else [substr a 19 (strlen a)-24 s]::res else res;; fun insertstring(s,l,f)= if l==nil then s::nil else let exec f with [s hd l] -> res in if res==0 then insertstring s tl l f else if res<0 then s::l else (hd l)::insertstring s tl l f;; fun sort(l,f)= if l==nil then nil else insertstring hd l sort tl l f f;; fun buildLanguages(path, bpath)= sort (buildl _listoffiles path bpath) @cmpbyclear;; /*fonction de hachage*/ fun hachage(ref)= let ((nth_char ref 0)+(nth_char ref 1))&255 -> x in if x==nil then 0 else x;; fun rebuild(l)= if l==nil then nil else let l->[a b] in if b==nil then a::nil else a::" "::rebuild b;; fun loadloc2(l)= if l==nil then 0 else let l->[[a b] n] in (if (nth_char a 0)!='# then let hachage a -> i in set tabloc.i=[a strcatn rebuild b]::tabloc.i else nil; loadloc2 n);; fun loadloc(file, lang)= set tabloc=mktab 256 nil; let strextr _getpack _checkpack strcatn file::"."::lang::".lang"::nil -> l in if l==nil then loadloc2 strextr _getpack _checkpack strcatn file::"."::defaultLanguage::".lang"::nil else loadloc2 l;; fun findloc(l, s)= if l==nil then "*" else let l->[[a b] n] in if !strcmp a s then b else findloc n s;; fun findloc2(l, s, def)= if l==nil then def else let l->[[a b] n] in if !strcmp a s then b else findloc2 n s def;; /* fonction de traduction */ fun strloc(s, l)= if l==nil then s else let (strfind "##" s 0) -> i in if i==nil then s else strcat substr s 0 i strcat hd l strloc substr s i+2 strlen s tl l;; /* fonction de traduction */ fun loc(s)= let hachage s -> i in findloc tabloc.i s;; /* fonction de traduction */ fun locDef(s, def)= let hachage s -> i in findloc2 tabloc.i s def;; /* fonction de chargement */ fun startloc(file)= if (currentLanguage != nil) then nil else set currentLanguage = _getress "DefaultLanguage"; loadloc file currentLanguage;; fun startlocEx(file, lang)= if (currentLanguage != nil) then nil else set currentLanguage = lang; loadloc file currentLanguage;; fun addloc2(file, lang)= let strextr _getpack _checkpack strcatn file::"."::lang::".lang"::nil -> l in if l==nil then loadloc2 strextr _getpack _checkpack strcatn file::"."::defaultLanguage::".lang"::nil else loadloc2 l;; fun addloc(file)= //_fooS strcat ">>>>>>>>>>>>>> loc : " file; if (currentLanguage != nil) then nil else set currentLanguage = _getress "DefaultLanguage"; addloc2 file currentLanguage;;