lJc@sdZddkZddkZddkZddkZddkZddkZddklZdddddd d d d d ddg Z ei i ei ddZ dZdZdZdd'dYZdefdYZddddZhZdddeddZdedddZhahadaddZddZddZdZd Z d!Z!d"Z"d#Z#d$Z$d%Z%d&Z&eZ'dS((sInternationalization and localization support. This module provides internationalization (I18N) and localization (L10N) support for your Python programs by providing an interface to the GNU gettext message catalog library. I18N refers to the operation by which a program is made aware of multiple languages. L10N refers to the adaptation of your program, once internationalized, to the local language and cultural habits. iN(tENOENTtNullTranslationstGNUTranslationstCatalogtfindt translationtinstallt textdomaintbindtextdomaintdgettextt dngettexttgettexttngettexttsharetlocalecCs|o|Sn|SdS(sy Implements the C expression: condition ? true : false Required to correctly interpret plural forms. N((t conditionttruetfalse((s/sys/lib/python/gettext.pyttest=sc syddkl}Wn#tj oddkl}nXddk}ddk}|i||i}yNg}|D]6}|d|ijo|ddjo ||qxqx~}Wn|ij ot dnX|o t dn|i d d }|i d d }t i d i d|}t i dfddg}x|D]} | djo|idqd| djoPt|djo t dni |i} |dcd| 7 ss4Is>IIsBad magic numberisFile is corruptt:is s content-typescharset=s plural-formst;splural=tN(tstructtunpacktgetattrt_catalogR-treadR*tLE_MAGICtBE_MAGICtIOErrortxrangeRIt splitlineststriptsplittlowerRHRJR4RYR9(RNRORntfilenametcatalogtbuftbuflentmagictversiontmsgcountt masteridxttransidxtiiREtmlentmofftmendttlenttoffttendtmsgttmsgtlastktktitemtvR-RURVR/R((s/sys/lib/python/gettext.pyRMsx     " "                  1   cCst}|ii||}||jo&|io|ii|Sn|Sn|io|i|iSn|io|i|iSn|S(N(tobjectRptgetRLR RKtencodeRJ(RNRStmissingR((s/sys/lib/python/gettext.pyR Ws     cCst}|ii||}||jo&|io|ii|Sn|Sn|io|i|iSn|itiS(N( RRpRRLRTRKRRtgetpreferredencoding(RNRSRR((s/sys/lib/python/gettext.pyRTes    cCsy`|i||i|f}|io|i|iSn|io|i|iSn|SWnPtj oD|io|ii|||Sn|djo|Sq|SnXdS(Ni(RpR-RKRRJtKeyErrorRLR (RNRURVRR((s/sys/lib/python/gettext.pyR ps    cCsyQ|i||i|f}|io|i|iSn|itiSWnPtj oD|io|ii|||Sn|djo|Sq|SnXdS(Ni( RpR-RKRRRRRLRW(RNRURVRR((s/sys/lib/python/gettext.pyRWs   cCs[t}|ii||}||jo,|io|ii|Snt|Sn|S(N(RRpRRLRXRY(RNRSRR((s/sys/lib/python/gettext.pyRXs   cCsy |i||i|f}Wn`tj oT|io|ii|||Sn|djot|}qt|}nX|S(Ni(RpR-RRLRZRY(RNRURVRR((s/sys/lib/python/gettext.pyRZs   ( RdReRrRsRMR RTR RWRXRZ(((s/sys/lib/python/gettext.pyRs Q    ic Csf|djo t}n|djofg}x;dD]3}tii|}|o|id}Pq1q1Wd|jo|idqng}xC|D];}x2t|D]$}||jo|i|qqWqW|o g} nd} xr|D]j}|djoPntii ||dd|} tii | o |o| i| q^| SqqW| S( NtLANGUAGEtLC_ALLt LC_MESSAGEStLANGRjtCs%s.mo(RRRR( RIt_default_localedirtostenvironRRxR)RGtpathtjointexists( tdomaint localedirt languagestalltenvarRFtnelangstlangtnelangtresulttmofile((s/sys/lib/python/gettext.pyRs@          c Cs|djo t}nt|||dd}|p(|o tSnttd|nd}x|D]}tii|} t i | } | djo%t i | |t |d} nt i | } |o| i|n|djo | }qk|i| qkW|S(NRis$No translation file found for domaintrb(RIRRRRtRRRtabspatht _translationsRt setdefaulttopentcopyR^RQ( RRRtclass_RRRAtmofilesRRtkeytt((s/sys/lib/python/gettext.pyRs*    %  cCs/t||dtd|}|i||dS(NRRRA(RtTrueR(RRRYRARcR((s/sys/lib/python/gettext.pyRstmessagescCs|dj o |antS(N(RIt_current_domain(R((s/sys/lib/python/gettext.pyRs  cCs+|dj o|t|s(((t__doc__RRRR'RmtsysterrnoRt__all__RRtprefixRRR4RGRRRIRRRfRRRRRRRRR RR RR RTR RWR(((s/sys/lib/python/gettext.pys s>&H   7 +T&