o 3az*@sdZddlZddlmZddlmZmZddlmZm Z ddl m Z ddl m Z ddlmZgd Zd ZGd d d eZGd ddZeZ[ddZddZddZddZddZddZddZddZe eeZe eeZ dd Z!dNd!d"Z"d#d$Z#dNd%d&Z$dNd'd(Z%dNd)d*Z&d+d,Z'd-d.Z(Gd/d0d0eZ)d1d2Z*d3d4Z+d5d6Z,d7d8Z-d9d:Z.dOdd?Z0d;d@dAdBZ1dCdDZ2dEdFZ3dGdHZ4edIZ5dJdKZ6dLdMZ7dS)Pz Internationalization support. N)ContextDecorator)ROUND_UPDecimal)autoreload_started file_changed)RemovedInDjango40Warning)lazy)_lazy_re_compile)activate deactivateoverridedeactivate_all get_languageget_language_from_requestget_language_infoget_language_bidicheck_for_language to_language to_locale templatizegettext gettext_lazy gettext_noopugettext ugettext_lazy ugettext_noopngettext ngettext_lazy ungettextungettext_lazypgettext pgettext_lazy npgettextnpgettext_lazyLANGUAGE_SESSION_KEY _languagec@s eZdZdS)TranslatorCommentWarningN)__name__ __module__ __qualname__r*r*C/usr/lib/python3/dist-packages/django/utils/translation/__init__.pyr&sr&c@seZdZdZddZdS)Transa The purpose of this class is to store the actual translation function upon receiving the first call to that function. After this is done, changes to USE_I18N will have no effect to which function is served upon request. If your tests rely on changing USE_I18N, you can delete all the functions from _trans.__dict__. Note that storing the function with setattr will have a noticeable performance effect, as access to the function goes the normal path, instead of using __getattr__. cCstddlm}|jr&ddlm}ddlm}m}tj |ddt j |ddnddlm }t ||t ||t ||S)Nr)settings) trans_real)translation_file_changedwatch_for_translation_changesr/) dispatch_uid) trans_null) django.confr-USE_I18Ndjango.utils.translationr.!django.utils.translation.reloaderr/r0rconnectrr2setattrgetattr)self real_namer-transr/r0r*r*r+ __getattr__7s    zTrans.__getattr__N)r'r(r)__doc__r=r*r*r*r+r,*s r,cC t|SN)_transrmessager*r*r+rL rcCtjdtddt|S)zx A legacy compatibility wrapper for Unicode handling on Python 2. Alias of gettext_noop() since Django 2.0. zkdjango.utils.translation.ugettext_noop() is deprecated in favor of django.utils.translation.gettext_noop(). stacklevel)warningswarnrrrBr*r*r+rP rcCr?r@)rArrBr*r*r+r]rDrcCrE)zs A legacy compatibility wrapper for Unicode handling on Python 2. Alias of gettext() since Django 2.0. zadjango.utils.translation.ugettext() is deprecated in favor of django.utils.translation.gettext().rFrG)rIrJrrrBr*r*r+rarKrcCst|||Sr@)rArsingularpluralnumberr*r*r+rnsrcCtjdtddt|||S)zt A legacy compatibility wrapper for Unicode handling on Python 2. Alias of ngettext() since Django 2.0. zcdjango.utils.translation.ungettext() is deprecated in favor of django.utils.translation.ngettext().rFrG)rIrJrrrLr*r*r+rr  rcC t||Sr@)rAr )contextrCr*r*r+r  r cCst||||Sr@)rAr"rSrMrNrOr*r*r+r"r"cCrE)z A legacy compatibility wrapper for Unicode handling on Python 2. Has been Alias of gettext_lazy since Django 2.0. zkdjango.utils.translation.ugettext_lazy() is deprecated in favor of django.utils.translation.gettext_lazy().rFrG)rIrJrrrBr*r*r+rrKrc s~ttrd<tdi}|SGfdddtfdddi}fdd|_|S)NrOcsJeZdZfddZfddZfddZfddZfd d Zd S) z&lazy_number..NumberAwareStringcs tdS)NrM)boolr:kwargsr*r+__bool__rTz/lazy_number..NumberAwareString.__bool__cs&z|WStytdw)Nz|Your dictionary lacks key '%s'. Please provide it, because it is required to determine whether string is singular or plural.)KeyError)r:valuesrOr*r+_get_number_values  z8lazy_number..NumberAwareString._get_number_valuecs|d<diS)NrOr*r*)r: number_value)funcrZr*r+ _translatesz1lazy_number..NumberAwareString._translatecs0|r r ||n|d}||j|i|S)Nr)r_rbformat)r:argsrZr`r^r*r+rcsz-lazy_number..NumberAwareString.formatcsLt|tr r ||}n|}||}z||}W|Sty%Y|Swr@) isinstancedictr_rb TypeError)r:rhsr` translatedr^r*r+__mod__s    z.lazy_number..NumberAwareString.__mod__N)r'r(r)r[r_rbrcrjr*)rarZrOr*r+NumberAwareStrings    rkcsSr@r*rY)rkr*r+szlazy_number..cstffSr@)_lazy_number_unpickler*)rarOoriginal_kwargs resultclassr*r+rlsr*)reintrcopy __reduce__)rarorOrZproxyr*)rkrarZrOrnror+ lazy_numbers )#rtcCst||fd|i|S)NrO)rt)rarorOrZr*r*r+rmsrmcCsttt|||dS)NrL)rtrstrrLr*r*r+rsrcCrP)z} A legacy compatibility wrapper for Unicode handling on Python 2. An alias of ungettext_lazy() since Django 2.0. zmdjango.utils.translation.ungettext_lazy() is deprecated in favor of django.utils.translation.ngettext_lazy().rFrG)rIrJrrrLr*r*r+rrQrcCsttt||||dS)NrU)rtr"rurUr*r*r+r#sr#cCr?r@)rAr )languager*r*r+r rDr cCtSr@)rAr r*r*r*r+r r c@s&eZdZd ddZddZddZdS) r FcCs||_||_dSr@)rvr )r:rvr r*r*r+__init__s zoverride.__init__cCs*t|_|jdurt|jdStdSr@)r old_languagervr r rXr*r*r+ __enter__s  zoverride.__enter__cCs2|jdur tdS|jrtdSt|jdSr@)rzr r r )r:exc_type exc_value tracebackr*r*r+__exit__s   zoverride.__exit__NF)r'r(r)ryr{rr*r*r*r+r s  r cCrwr@)rArr*r*r*r+rrxrcCrwr@)rArr*r*r*r+rrxrcCr?r@)rAr) lang_coder*r*r+rrDrcCsB|d}|dkr|d|d||ddS|S)z8Turn a locale name (en_US) into a language name (en-us)._rN-)findlower)localepr*r*r+r s (rcCsd|d\}}}|s|S|d\}}}t|dkr |n|}|r,|d|7}|d|S)z8Turn a language name (en-us) into a locale name (en_US).rrFr)r partitionlentitleupper)rvrcountrytailr*r*r+rs  rFcCrRr@)rAr)request check_pathr*r*r+r"rTrcCr?r@)rAget_language_from_path)pathr*r*r+r&rDr)strictcCrRr@)rAget_supported_language_variant)rrr*r*r+r*rTrcKsddlm}||fi|S)Nr)r)templater)srcrZrr*r*r+r.s rcCrwr@)rAr r*r*r*r+r 3rxr c Csddlm}z||}d|vrd|vrt|dd}n|}Wn0tyOd|vr0td||dd}z||}WntyLtd||fwYnw|rZt|d|d<|S) Nr) LANG_INFOfallbacknamerzUnknown language code %s.z Unknown language code %s and %s.name_translated)django.conf.localerrr\splitr)rr lang_infoinfogeneric_lang_coder*r*r+r7s*      rz\s*\n\s*cCstd|S)N )trim_whitespace_resubstrip)sr*r*r+trim_whitespacePrVrcCs"tt|djtdtddS)Nr0)rounding)rprquantizer)valuer*r*r+round_away_from_oneTs"rr@r)8r>rI contextlibrdecimalrrdjango.utils.autoreloadrrdjango.utils.deprecationrdjango.utils.functionalrdjango.utils.regex_helperr __all__r$ SyntaxWarningr&r,rArrrrrrr r"rurr!rrtrmrrr#r r r rrrrrrrrrr rrrrr*r*r*r+s^           /