Ñò ,@ŽIc@s-dZddkZddklZlZddkZdddddd d d d d dddddgZdefd„ƒYZde fd„ƒYZ d„Z d„Z e Z d„Ze eƒZd„ZeZe eƒZd„Ze eƒZd„Ze eƒZd„Zd„Zd„Zd„ZdS( s±Translation/Localization functions. Provides :mod:`gettext` translation functions via an app's ``pylons.translator`` and get/set_lang for changing the language translated to. iÿÿÿÿN(tNullTranslationst translationt_t add_fallbacktget_langtgettextt gettext_noopt lazy_gettextt lazy_ngettextt lazy_ugettexttlazy_ungettexttngettexttset_langtugettextt ungettextt LanguageErrortN_cBseZdZRS(s>Exception raised when a problem occurs with changing languages(t__name__t __module__t__doc__(((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyRst LazyStringcBs;eZdZd„Zd„Zd„Zd„Zd„ZRS(sµHas a number of lazily evaluated functions replicating a string. Just override the eval() method to produce the actual value. This method copied from TurboGears. cOs||_||_||_dS(N(tfunctargstkwargs(tselfRRR((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyt__init__s  cCs|i|i|iŽS(N(RRR(R((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyteval#scCst|iƒƒS(N(tunicodeR(R((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyt __unicode__&scCst|iƒƒS(N(tstrR(R((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyt__str__)scCs|iƒ|S(N(R(Rtother((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyt__mod__,s(RRRRRRRR (((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyRs     csV‡fd†}ydˆi|_Wntj onXdˆiˆif|_|S(s<Decorator to return a lazy-evaluated version of the originalcstˆ||ŽS(N(R(RR(R(s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pytnewfunc2sslazy_%ss-Lazy-evaluated version of the %s function %s(Rt TypeErrorR(RR!((Rs;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pytlazify0scCs|S(sMark a string for translation without translating it. Returns value. Used for global strings, e.g.:: foo = N_('Hello') class Bar: def __init__(self): self.local_foo = _(foo) h.set_lang('fr') assert Bar().local_foo == 'Bonjour' h.set_lang('es') assert Bar().local_foo == 'Hola' assert foo == 'Hello' ((tvalue((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyR=scCstii|ƒS(s·Mark a string for translation. Returns the localized string of value. Mark a string to be localized as follows:: gettext('This should be in lots of languages') (tpylonst translatorR(R$((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyRTs cCstii|ƒS(s½Mark a string for translation. Returns the localized unicode string of value. Mark a string to be localized as follows:: _('This should be in lots of languages') (R%R&R (R$((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyR as cCstii|||ƒS(sìMark a string for translation. Returns the localized string of the pluralized value. This does a plural-forms lookup of a message id. ``singular`` is used as the message id for purposes of lookup in the catalog, while ``n`` is used to determine which plural form to use. The returned message is a string. Mark a string to be localized as follows:: ngettext('There is %(num)d file here', 'There are %(num)d files here', n) % {'num': n} (R%R&R (tsingulartpluraltn((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyR oscCstii|||ƒS(sþMark a string for translation. Returns the localized unicode string of the pluralized value. This does a plural-forms lookup of a message id. ``singular`` is used as the message id for purposes of lookup in the catalog, while ``n`` is used to determine which plural form to use. The returned message is a Unicode string. Mark a string to be localized as follows:: ungettext('There is %(num)d file here', 'There are %(num)d files here', n) % {'num': n} (R%R&R(R'R(R)((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyR‚sc Ks|ptƒSd|jo|idƒ}ntiiƒ}y|dd}Wn&tj o|didƒ}nXtii |dƒ}t |t ƒp |g}ny t |d|d||}Wn%t j o}td|ƒ‚nX||_|S( sHUtility method to get a valid translator object from a language namet pylons_configs pylons.pathstroott root_pathti18nspylons.packaget languagess IOError: %s(RtpopR%tconfigt current_conftKeyErrortgettostpathtjoint isinstancetlistRtIOErrorRt pylons_lang(tlangRtconftrootdirt localedirR&tioe((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyt_get_translator•s&   cKsTt||}tii}||d_d|jo|diti|ƒndS(säSet the current language used for translations. ``lang`` should be a string or a list of strings. If a list of strings, the first language is set as the main and the subsequent languages are added as fallbacks. s pylons.pylonsspaste.registryN(R@R%trequesttenvironR&treplace(R;RR&RB((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyR ¯s    cCsttiddƒS(s%Return the current i18n language usedR:N(tgetattrR%R&tNone(((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyR½scKstiit||ƒS(sYAdd a fallback language from which words not matched in other languages will be translated to. This fallback will be associated with the currently selected language -- that is, resetting the language via set_lang() resets the current fallbacks. This function can be called multiple times to add multiple fallbacks. (R%R&RR@(R;R((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyRÂs (RR4RRRR%t__all__t ExceptionRtobjectRR#RRRR RR R RRR R@R RR(((s;/usr/lib/python2.6/site-packages/pylons/i18n/translation.pyts2