Commit 57d9196c authored by Benoît Minisini's avatar Benoît Minisini

The defaut country of language collection has been replaced by a string, faster to initialize.

[GB.WEB]
* OPT: The defaut country of language collection has been replaced by a string, faster to initialize.
parent db50637b
......@@ -2,7 +2,24 @@
Public AllowLog As Boolean
Private $cLang As Collection
Private Const DEFAULT_LANG_DICT As String = ""
":aa=ER:af=ZA:afr=PE:ak=GH:am=ET:an=ES:anp=IN:ar=EG:as=IN:ast=ES:ayc=PE:az=AZ"
":be=BY:bem=ZM:ber=MA:bg=BG:bhb=IN:bho=IN:bi=VU:bd=BD:bo=CN:br=FR:brx=IN:bs=BA"
":byn=ER:ca=ES:chr=US:ckb=IQ:cmn=TW:crh=UA:csb=PL:cs=CZ:cv=RU:cy=GB:da=DK:de=DE"
":doi=IN:dsb=DE:dv=MV:dz=BT:el=GR:en=GB:eo=US:es=ES:et=EE:eu=ES:fa=IR:ff=SN:fi=FI"
":fil=PH:fo=FO:fr=FR:fur=IT:fy=NL:ga=IE:gd=GB:gez=ET:gl=ES:gu=IN:gv=GB:hak=TW"
":ha=NG:he=IL:hif=FJ:hi=IN:hne=IN:hr=HR:hsb=DE:ht=HT:hu=HU:hy=AM:ia=FR:id=ID"
":ig=NG:ik=CA:is=IS:it=IT:iu=CA:ja=JP:kab=DZ:ka=GE:kk=KZ:kl=GL:km=KH:kn=IN:kok=IN"
":ko=KR:ks=IN:ku=TR:kw=GB:ky=KG:lb=LU:lg=UG:li=NL:lij=IT:ln=CD:lo=LA:lt=LT:lv=LV"
":lzh=TW:mag=IN:mai=IN:mfe=MU:mg=MG:mhr=RU:mi=NZ:miq=NI:mjw=IN:mk=MK:ml=IN:mni=IN"
":mn=MN:mr=IN:ms=MY:mt=MT:my=MM:nan=TW:nb=NO:nds=DE:ne=NP:nhn=MX:niu=NZ:nl=NL"
":nn=NO:nr=ZA:nso=ZA:oc=FR:om=ET:or=IN:os=RU:pa=PK:pap=CW:pl=PL:ps=AF:pt=PT:quz=PE"
":raj=IN:ro=RO:ru=RU:rw=RW:sah=RU:sa=IN:sat=IN:sc=IT:sd=PK:se=NO:sgs=LT:shn=MM"
":shs=CA:sid=ET:si=LK:sk=SK:sl=SI:sm=WS:so=SO:sq=AL:sr=RS:ss=ZA:st=ZA:sv=SE:sw=KE"
":szl=PL:ta=LK:tcy=IN:te=IN:tg=TJ:the=NP:th=TH:ti=ER:tig=ER:tk=TM:tl=PH:tn=ZA"
":to=TO:tpi=PG:tr=TR:ts=ZA:tt=RU:ug=CN:uk=UA:unm=US:ur=PK:uz=UZ:ve=ZA:vi=VN:wa=BE"
":wae=CH:wal=ET:wo=SN:xh=ZA:yi=US:yo=NG:yue=HK:yuw=PG:zh=CN:zu=ZA:"
Public Sub Log(sMsg As String, Optional bForce As Boolean)
......@@ -77,8 +94,9 @@ End
Public Sub Main()
CGI["HTTP_ACCEPT_LANGUAGE"] = "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3"
Print Request.Language
'CGI["HTTP_ACCEPT_LANGUAGE"] = "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3"
'Print Request.Language
MakeLanguage
End
......@@ -87,7 +105,8 @@ End
Private Sub MakeLanguage()
Dim cLang As New Collection
Dim hFile As File
Dim sVal As String
Dim sStr As String
cLang["aa"] = "ER"
cLang["af"] = "ZA"
......@@ -288,26 +307,31 @@ Private Sub MakeLanguage()
cLang["zh"] = "CN"
cLang["zu"] = "ZA"
hFile = Open "~/gambas/git/master/comp/src/gb.web/lang.cache" For Create
Write #hFile, cLang As Collection
Close #hFile
For Each sVal In cLang
sStr &= ":" & cLang.Key & "=" & sVal
If Len(sStr) > 74 Then
Print Quote(sStr)
sStr = ""
Endif
Next
Print Quote(sStr & ":")
End
Public Sub ToLanguage(sLang As String) As String
Dim hFile As File
Dim sCountry As String
Dim iPos As Integer
Dim sFind As String
If InStr(sLang, "-") = 0 Then
If Not $cLang Then
hFile = Open "lang.cache" For Read
$cLang = Read #hFile As Collection
Close #hFile
Endif
sFind = ":" & LCase(sLang) & "="
iPos = InStr(DEFAULT_LANG_DICT, sFind)
If iPos = 0 Then Return System.Language
sCountry = $cLang[LCase(sLang)]
sCountry = Mid$(DEFAULT_LANG_DICT, iPos + Len(sFind), 2)
If Not sCountry Then Return System.Language
Return sLang & "_" & sCountry & ".UTF-8"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment