mò DµMc@sodZdkZdkZdkZdkZdkZdkZdkZdkl Z dk Z dk l Z dddgZ e iiZddd d d ZeieeiƒZeid ƒZd „Zd„Zd„Zd„Zdefd„ƒYZdefd„ƒYZdd„Zd„Zd„Zei eeeƒd„Z!e"djodk#Z#e#i$ƒndS(s¢ This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html) N(slistdir(sgetcfst translatortfindTtupdate_all_languagess(?<=[^\w]T\()(?Ps*[uU]?[rR]?(?:'''(?:[^']|'{1,2}(?!'))*''')|s(?:'(?:[^'\\]|\\.)*')|s (?:"""(?:[^"]|"{1,2}(?!"))*""")|s(?:"(?:[^"\\]|\\.)*"))s+^[a-zA-Z]{2}(\-[a-zA-Z]{2})?(\-[a-zA-Z]+)?$cCs—t|dƒ}ti|tiƒ|iƒiddƒ}ti |ƒ|i ƒ|i ƒphSnyt |ƒSWnt id|ƒhSnXdS(Ntrs s sSyntax error in %s(topentfilenametfpt portalockertlocktLOCK_SHtreadtreplacet lang_texttunlocktclosetstriptevaltloggingterror(RRR ((t9/home/camdpams_www/Products_Activation/gluon/languages.pyt read_dict_aux(s   cCstd|||d„ƒS(Ns language:%scCs t|ƒS(N(RR(R((Rt8s(tgetcfsR(R((Rt read_dict6s cCsˆ|idƒdjo2|idƒdjodid|dgƒ}n%did|iddƒdgƒ}|iddƒidd ƒS( s¤ # note that we use raw strings to avoid having to use double back slashes below utf8_repr() works same as repr() when processing ascii string >>> utf8_repr('abc') == utf8_repr("abc") == repr('abc') == repr("abc") == "'abc'" True >>> utf8_repr('a"b"c') == repr('a"b"c') == '\'a"b"c\'' True >>> utf8_repr("a'b'c") == repr("a'b'c") == '"a\'b\'c"' True >>> utf8_repr('a\'b"c') == repr('a\'b"c') == utf8_repr("a'b\"c") == repr("a'b\"c") == '\'a\\\'b"c\'' True >>> utf8_repr('a\r\nb') == repr('a\r\nb') == "'a\\r\\nb'" # Test for \r, \n True Unlike repr(), utf8_repr() remains utf8 content when processing utf8 string >>> utf8_repr('中文字') == utf8_repr("中文字") == "'中文字'" != repr('中文字') True >>> utf8_repr('中"æ–‡"å­—') == "'中\"æ–‡\"å­—'" != repr('中"æ–‡"å­—') True >>> utf8_repr("中'æ–‡'å­—") == '"中\'æ–‡\'å­—"' != repr("中'æ–‡'å­—") True >>> utf8_repr('中\'æ–‡"å­—') == utf8_repr("中'æ–‡\"å­—") == '\'中\\\'æ–‡"å­—\'' != repr('中\'æ–‡"å­—') == repr("中'æ–‡\"å­—") True >>> utf8_repr('中\r\næ–‡') == "'中\\r\\næ–‡'" != repr('中\r\næ–‡') # Test for \r, \n True t'it"ts\'s s\ns s\rN(tstfindtjoinR (R((Rt utf8_repr:s ,$cCsÄyt|dƒ}Wn(tj otid|ƒdSnXti|tiƒ|i dƒx;t |ƒD]-}|i dt |ƒt ||ƒfƒqkW|i dƒti|ƒ|iƒdS(NtwsUnable to write to file %ss# coding: utf8 { s%s: %s, s} (RRRtIOErrorRRRRtLOCK_EXtwritetsortedtcontentstkeyRR R(RR$RR%((Rt write_dict\s   +  tlazyTcBsÑtZdZeZeZeZhed„Zd„Zd„Z d„Z d„Z d„Z d„Z d„Zd „Zd „Zd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„ZRS(sH never to be called explicitly, returned by translator.__call__ cCs||_||_||_dS(N(tmessagetselftmtsymbolsRtT(R)R(R+R,((Rt__init__us  cCsdtt|iƒƒfS(Ns (treprtstrR)R*(R)((Rt__repr__scCs|ii|i|iƒS(N(R)R,t translateR*R(R)((Rt__str__‚scCs|ii|i|iƒ|jS(N(R)R,R1R*Rtother(R)R3((Rt__eq__…scCs|ii|i|iƒ|jS(N(R)R,R1R*RR3(R)R3((Rt__ne__ˆscCsd||fS(Ns%s%s(R)R3(R)R3((Rt__add__‹scCsd||fS(Ns%s%s(R3R)(R)R3((Rt__radd__ŽscCstt|ƒt|ƒƒS(N(tcmpR/R)R3(R)R3((Rt__cmp__‘scCstt|ƒƒS(N(thashR/R)(R)((Rt__hash__”scCstt|ƒ|ƒS(N(tgetattrR/R)tname(R)R=((Rt __getattr__—scCst|ƒ|S(N(R/R)ti(R)R?((Rt __getitem__šscCst|ƒ||!S(N(R/R)R?tj(R)R?RA((Rt __getslice__sccsxt|ƒD] }|Vq WdS(N(R/R)tc(R)RC((Rt__iter__ s cCstt|ƒƒS(N(tlenR/R)(R)((Rt__len__£scCstit|ƒƒS(N(tcgitescapeR/R)(R)((Rtxml¦scOst|ƒi||ŽS(N(R/R)tencodetatb(R)RKRL((RRJ©scOst|ƒi||ŽS(N(R/R)tdecodeRKRL(R)RKRL((RRM¬scCs t|ƒS(N(R/R)(R)((RR ¯scCs|ii|i|ƒS(N(R)R,R1R*R+(R)R+((Rt__mod__²s(t__name__t __module__t__doc__tNoneR*RR,R-R0R2R4R5R6R7R9R;R>R@RBRDRFRIRJRMR RN(((RR'ks.                  cBsGtZdZd„Zd„Zd„Zd„Zhd„Zd„ZRS(sæ this class is instantiated by gluon.compileapp.build_environment as the T object :: T.force(None) # turns off translation T.force('fr, it') # forces web2py to translate using fr.py or it.py T("Hello World") # translates "Hello World" using the selected file notice 1: there is no need to force since, by default, T uses accept_language to determine a translation file. notice 2: en and en-en are considered different languages! cCs[|i|_dg|_d|_d|_|ii|_|i |iƒ|_ t |_ dS(Nten( trequesttfolderR)tcurrent_languagesRRtaccepted_languaget language_filetenvthttp_accept_languagetforcetrequested_languagestTruetlazy(R)RT((RR-És    cCsu|i}tidƒ}xVtitii |i dƒƒD]3}|i |ƒo|i |id|ƒƒq:q:W|S(Ns\.py$t languagesR(R)RVtpossible_languagestretcompilet file_endingtostlistdirtpathRRUtlangfiletsearchtappendtsub(R)RcRgR`((Rtget_possible_languagesÒs "!cGsXt|ƒdjo(t|dttfƒo|d}n||_|i|iƒdS(Nii( RER_t isinstancettupletlistR)RVR[RZ(R)R_((Rtset_current_languagesÚs- cGs°| p|ddjo g}nt|ƒdjo(t|dttfƒo|d}n|o5t|ttfƒo‘|idƒ}g}g}|D]}||i |idƒƒq›~g}|D]3}t i |iƒƒo||iƒiƒqÌqÌ~}nx‹|D]}||ijo||_Pntii|id|dƒ}tii|ƒo)||_||_t|ƒ|_|SqqWnd|_h|_|S(Niit;t,s languages/s.py(R_RRRERlR/tunicodetsplittaccept_languagest_[1]taltextendtitemtregex_languagetmatchRtlowertlanguageR)RVRWRdRfRRURtexistsRXRtt(R)R_RuR|RtRvRRx((RR[às0 -1K     cCs2|iot|||ƒSn|i||ƒSdS(N(R)R^R'R(R+R1(R)R(R+((Rt__call__ûs cCs |idƒ o#d|jo|iddƒ}n |g}t|ƒdjo4|diƒ|d<|dd|diƒ}n|ii|dƒ}|djoB|d|i|<}|i ot ot |i |iƒqèn|p |djo ||Sn|S(s user ## to add a comment into a translation string the comment can be useful do discriminate different possible translations for the same string (for example different locations) T(' hello world ') -> ' hello world ' T(' hello world ## token') -> 'hello world' T('hello ## world ## token') -> 'hello ## world' the ## notation is ignored in multiline strings and strings that start with ##. this is to allow markmin syntax to be translated t#s s##iiiN(R(t startswithtrsplitttokensRERR)R~tgetRRtmtRXtis_gaeR&R+(R)R(R+RƒR…((RR1s     ( RORPRQR-RkRoR[RR1(((RR¶s     sen-uscCsÌtii|dd|ƒ}t|ƒ}tii|dƒ} tii|dƒ}tii|dƒ}xQt | ddƒt |ddƒt |ddƒD]}t |d ƒ}ti|tiƒ|iƒ} ti|ƒ|iƒti| ƒ} xÀ| D]¸} y¨t| ƒ}|id ƒ o#d |jo|id d ƒ} n |g} t| ƒdjo&| diƒd | d iƒ}n|o||jo|||