Repository URL to install this package:
Version:
4.0.109 ▾
|
ó ƍEYc @ s¬ d Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m Z d Z e j e Z d e j f d YZ d S( s4 Private Message class for lazy translation support. iÿÿÿÿN( t _locale( t _translates t Messagec B s e Z d Z d d d e e d Z d d Z e d e e d Z d Z d Z d Z d Z d Z d Z RS( sý A Message object is a unicode object that can be translated. Translation of Message is done explicitly using the translate() method. For all non-translation intents and purposes, a Message is simply unicode, and can be treated as such. t osloc G sg | s t j | | } n t t | j | | } | | _ | | _ | | _ | | _ | | _ | S( s& Create a new Message object. In order for translation to work gettext requires a message ID, this msgid will be used as the base unicode text. It is also possible for the msgid and the base unicode text to be different by passing the msgtext parameter. ( R t _translate_msgidt supert __new__t msgidt domaint paramst has_contextual_formt has_plural_form( t clsR t msgtextR R R R t argst msg( ( sG /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_i18n/_message.pyR . s c C s_ t j | j | j | | j | j } | j d k r: | St j | j | } | j | | S( sQ Translate this message to the desired locale. :param desired_locale: The desired locale to translate the message to, if no locale is provided the message will be translated to the system's default locale. :returns: the translated message in unicode N( R R R R R R R t NoneR t translate_argst _safe_translate( t selft desired_localet translated_messaget translated_params( ( sG /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_i18n/_message.pyt translateG s c C sy | s: t j } | s$ | d r- d } q: | d } n t j j t j | } t j | d | d | g d t } | r± | r± t j r | j n | j } | | } nÄ | rÌ | rÌ t d n© | r0| \ } } t j rð | j n | j } d | t | f } | | } t | k ru| } qunE | ru| \ } } } t j rW| j n | j } | | | | } n | S( Ni t en_USt localedirt languagest fallbacks Unimplemented.s %s%s%s( t localet getdefaultlocalet ost environt getR t get_locale_dir_variable_namet gettextt translationt Truet sixt PY3t ugettextt ValueErrort CONTEXT_SEPARATORt ngettextt ungettext( R R R R R t system_localet locale_dirt langt translatorR t msgctxt msgtxtt msg_with_ctxt msgsinglet msgpluralt msgcount( ( sG /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_i18n/_message.pyR d s8 c C sw y | | } Wnb t t f k rr } d } t j | | | j | f t j | | | j | | j | } n X| S( sÈ Trap translation errors and fall back to default translation. :param translated_message: the requested translation :param translated_params: the params to be inserted :return: if parameter insertion is successful then it is the translated_message with the translated_params inserted, if the requested translation fails then it is the default translation with the params uQ Failed to insert replacement values into translated message %s (Original: %r): %s( t KeyErrort TypeErrort warningst warnR t LOGt debug( R R R t errR ( ( sG /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_i18n/_message.pyR s c C sR | j | } | j t j | | } t | j d | d | d | j } | S( NR R R ( t _sanitize_mod_paramsR R% t text_typeR R R ( R t otherR t unicode_modt modded( ( sG /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_i18n/_message.pyt __mod__· s c s¡ | d k r | f } n t | t r i } t j t rh | j f d j j D n | j f d | j D n j | } | S( s Sanitize the object being modded with this Message. - Add support for modding 'None' so translation supports it - Trim the modded object, which can be a large dictionary, to only those keys that would actually be used in a translation - Snapshot the object being modded, in case the message is translated, it will be used as it was when the Message was created c 3 s* | ] \ } } | j | f Vq d S( N( t _copy_param( t .0t keyt val( R ( sG /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_i18n/_message.pys <genexpr>Ó s c 3 s* | ] \ } } | j | f Vq d S( N( RC ( RD RE RF ( R ( sG /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_i18n/_message.pys <genexpr>Õ s N( R t isinstancet dictR t updatet itemsRC ( R R? R ( ( R sG /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_i18n/_message.pyR= Ã s c C s3 y t j | SWn t k r. t j | SXd S( N( t copyt deepcopyt ExceptionR% R>