^Rc @sdZddlZddlZddlZddlZddlZddlZddlmZdddddd d d d d ddg Z ej j ej ddZ dZdZdZdd'dYZdefdYZddddZiZdddeddZdedddZiaiadaddZddZddZdZd 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|r |S|SdS(sy Implements the C expression: condition ? true : false Required to correctly interpret plural forms. N((t conditionttruetfalse((s/usr/lib/python2.7/gettext.pyttest=sc syddlm}Wn!tk r7ddlm}nXddl}ddl}|j||j}y@g|D]/}|d|jkrr|ddkrr|^qr}Wn|jk rt dnX|rt dn|j d d }|j d d }t j d j d|}t j dfddg}x|D]}|dkrr|jdqP|dkrt|dkrt dnj |j} |dcd| 7 @       cCsddlm}||}d }d }d }d}|jd}|dkrp||}|| }||O}nd}|jd}|dkr||}|| }||O}nd}|jd }|dkr||} || }||O}nd} |} g} x~t|dD]l} | |@s| } | |@rE| | 7} n| |@r\| |7} n| |@rs| |7} n| j| qqW| j| S( Ni(t normalizeiiit@Rt.t_iii(RR4RtrangeR)treverse(RR4tCOMPONENT_CODESETtCOMPONENT_TERRITORYtCOMPONENT_MODIFIERtmasktpostmodifiertcodesett territorytlanguagetrettitval((s/usr/lib/python2.7/gettext.pyt _expand_langsL                  cBseZddZdZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zedd ZRS(cCsDi|_d|_d|_d|_|dk r@|j|ndS(N(t_infotNonet_charsett_output_charsett _fallbackt_parse(tselftfp((s/usr/lib/python2.7/gettext.pyt__init__s      cCsdS(N((RMRN((s/usr/lib/python2.7/gettext.pyRLscCs)|jr|jj|n ||_dS(N(RKt add_fallback(RMtfallback((s/usr/lib/python2.7/gettext.pyRPs cCs|jr|jj|S|S(N(RKR (RMtmessage((s/usr/lib/python2.7/gettext.pyR s cCs|jr|jj|S|S(N(RKtlgettext(RMRR((s/usr/lib/python2.7/gettext.pyRSs cCs7|jr|jj|||S|dkr/|S|SdS(Ni(RKR (RMtmsgid1tmsgid2R((s/usr/lib/python2.7/gettext.pyR s   cCs7|jr|jj|||S|dkr/|S|SdS(Ni(RKt lngettext(RMRTRUR((s/usr/lib/python2.7/gettext.pyRVs   cCs#|jr|jj|St|S(N(RKtugettexttunicode(RMRR((s/usr/lib/python2.7/gettext.pyRWs cCsC|jr|jj|||S|dkr5t|St|SdS(Ni(RKt ungettextRX(RMRTRUR((s/usr/lib/python2.7/gettext.pyRYs    cCs|jS(N(RG(RM((s/usr/lib/python2.7/gettext.pytinfoscCs|jS(N(RI(RM((s/usr/lib/python2.7/gettext.pytcharsetscCs|jS(N(RJ(RM((s/usr/lib/python2.7/gettext.pytoutput_charsetscCs ||_dS(N(RJ(RMR[((s/usr/lib/python2.7/gettext.pytset_output_charsetscCsddl}|r|jp!|j|jd ss4Is>IIsBad magic numberisFile is corruptt#t:is s content-typescharset=s plural-formst;splural=tN(tstructtunpacktgetattrt_catalogR-treadR*tLE_MAGICtBE_MAGICtIOErrortxrangeRHt splitlineststript startswithtsplittlowerRGRIR3RXR8(RMRNRntfilenametcatalogtbuftbuflentmagictversiontmsgcountt masteridxttransidxtiiRDtmlentmofftmendttlenttoffttendtmsgttmsgtlastktktitemtvR-RTRUR((s/usr/lib/python2.7/gettext.pyRLsv     " "                 (   cCs}t}|jj||}||krG|jrC|jj|S|S|jr`|j|jS|jry|j|jS|S(N(tobjectRptgetRKR RJtencodeRI(RMRRtmissingR((s/usr/lib/python2.7/gettext.pyR Ys     cCsst}|jj||}||krG|jrC|jj|S|S|jr`|j|jS|jtjS(N( RRpRRKRSRJRRtgetpreferredencoding(RMRRRR((s/usr/lib/python2.7/gettext.pyRSgs    cCsyV|j||j|f}|jr8|j|jS|jrQ|j|jS|SWnDtk r|jr|jj|||S|dkr|S|SnXdS(Ni(RpR-RJRRItKeyErrorRKR (RMRTRURR((s/usr/lib/python2.7/gettext.pyR rs     cCsyL|j||j|f}|jr8|j|jS|jtjSWnDtk r|jr{|jj|||S|dkr|S|SnXdS(Ni( RpR-RJRRRRRKRV(RMRTRURR((s/usr/lib/python2.7/gettext.pyRVs    cCsQt}|jj||}||krM|jrC|jj|St|S|S(N(RRpRRKRWRX(RMRRRR((s/usr/lib/python2.7/gettext.pyRWs    cCs~y |j||j|f}WnWtk ry|jrO|jj|||S|dkrjt|}qzt|}nX|S(Ni(RpR-RRKRYRX(RMRTRURR((s/usr/lib/python2.7/gettext.pyRYs    ( RcRdRrRsRLR RSR RVRWRY(((s/usr/lib/python2.7/gettext.pyRs S    ic CsT|dkrt}n|dkrg}x9dD]1}tjj|}|r.|jd}Pq.q.Wd|kr|jdqng}xA|D]9}x0t|D]"}||kr|j|qqWqW|rg} nd} xl|D]d}|dkrPntjj ||dd|} tjj | r|rE| j| qL| SqqW| S( NtLANGUAGEtLC_ALLt LC_MESSAGEStLANGRjtCs%s.mo(RRRR( RHt_default_localedirtostenvironRRyR)RFtpathtjointexists( tdomaint localedirt languagestalltenvarREtnelangstlangtnelangtresulttmofile((s/usr/lib/python2.7/gettext.pyRs8           c Cs|dkrt}nt|||dd}|sU|r@tSttd|nd}x|D]}|tjj|f} t j | } | dkrt |d} t j | || } WdQXnt j | } |r| j|n|dkr| }qb|j| qbW|S(NRis$No translation file found for domaintrb(RHRRRRtRRRtabspatht _translationsRtopent setdefaulttcopyR]RP( RRRtclass_RQR@tmofilesRRtkeyttRN((s/usr/lib/python2.7/gettext.pyRs*    !  cCs/t||dtd|}|j||dS(NRQR@(RtTrueR(RRRXR@RbR((s/usr/lib/python2.7/gettext.pyRstmessagescCs|dk r|antS(N(RHt_current_domain(R((s/usr/lib/python2.7/gettext.pyRs  cCs)|dk r|t| s>&H   7 +T&