jf{UdZddlmZddlZddlZddlmZmZddlm Z m Z ddl m Z ddl mZgdZe rdd lmZmZed Zd ed <d ed<daeiZdZdtdZiddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5id6d7d8d9d:d;dd?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]ZGd^d_eZGd`daZdefdudfZdgefdvdmZ dwdxdpZ dwdydsZ dS)zz babel.core ~~~~~~~~~~ Core locale representation and locale data access. :copyright: (c) 2013-2023 by the Babel Team. :license: BSD, see LICENSE for more details. ) annotationsN)IterableMapping) TYPE_CHECKINGAny) localedata) PluralRule)UnknownLocaleErrorLocaledefault_localenegotiate_locale parse_locale)Literal TypeAlias)all_currenciescurrency_fractionslanguage_aliaseslikely_subtagsparent_exceptionsscript_aliasesterritory_aliasesterritory_currenciesterritory_languagesterritory_zonesvariant_aliaseswindows_zone_mapping zone_aliaseszone_territoriesr _GLOBAL_KEYz.Mapping[_GLOBAL_KEY, Mapping[str, Any]] | None _global_datac td)NzThe babel data files are not available. This usually happens because you are using a source checkout from Babel and you did not build the data files. Just make sure to run "python setup.py import_cldr" before installing the library.) RuntimeErrorj/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/babel/core.py_raise_no_data_errorr&2s 1 2 22r$keyreturnMapping[str, Any]cttjtjt }tj|d}tj|stt|d5}tj |atJ dddn #1swxYwYt |iS)a_Return the dictionary for the given key in the global data. The global data is stored in the ``babel/global.dat`` file and contains information independent of individual locales. >>> get_global('zone_aliases')['UTC'] u'Etc/UTC' >>> get_global('zone_territories')['Europe/Berlin'] u'DE' The keys available are: - ``all_currencies`` - ``currency_fractions`` - ``language_aliases`` - ``likely_subtags`` - ``parent_exceptions`` - ``script_aliases`` - ``territory_aliases`` - ``territory_currencies`` - ``territory_languages`` - ``territory_zones`` - ``variant_aliases`` - ``windows_zone_mapping`` - ``zone_aliases`` - ``zone_territories`` .. note:: The internal structure of the data may change between versions. .. versionadded:: 0.9 :param key: the data key Nz global.datrb) r ospathjoindirname__file__isfiler&openpickleloadget)r'r/filenamefileobjs r% get_globalr8;sF',,rwx88997<<66w~~h'' # " " " (D ! ! ,W!;w//L++++ , , , , , , , , , , , , , , ,   C $ $$s&CCCarar_SYbgbg_BGbsbs_BAcaca_EScscs_CZdada_DKdede_DEelel_GRenen_USeses_ESetet_EEfafa_IRfifi_FIfrfr_FRglgl_EShehe_ILhuhu_HUidid_IDisis_ISitit_ITjaja_JPkmkm_KHkoko_KRltlt_LTlvlv_LVmkmk_MKnlnl_NLnnnn_NOnonb_NOplpl_PLptpt_PTroro_ROruru_RUsksk_SKsl_SIsv_SEth_THtr_TRuk_UA)slsvthtrukceZdZdZddZdS) r z[Exception thrown when a locale is requested for which no locale data is available. identifierstrr(NonecPt|d|||_dS)zjCreate the exception. :param identifier: the identifier string of the unsupported locale zunknown locale N) Exception__init__r)selfrs r%rzUnknownLocaleError.__init__zs0 4!A:!A!ABBB%r$N)rrr(r)__name__ __module__ __qualname____doc__rr#r$r%r r us2%%%%%%r$r ceZdZdZ d\d]d Zedefd^dZedefd_dZe d`dadZ dbd Z dbd!Z dcd#Z ddd$Z ddd%Zeded'Zdfdgd*Zeed+,Zdfdgd-Zeed.,Zdfdgd/Zeed0,Zdfdgd1Zeed2,Zedhd3Zeded4Zeded5Zeded6Zeded7Zeded8Zeded9Zeded:Z eded;Z!eded<Z"eded=Z#eded>Z$eded?Z%eded@Z&ededAZ'ededBZ(ededCZ)ededDZ*ededEZ+ededFZ,ededGZ-ededHZ.ededIZ/ededJZ0edcdKZ1edcdLZ2edcdMZ3edcdNZ4ededOZ5ededPZ6ededQZ7ededRZ8ededSZ9edidUZ:ededVZ;edidWZedddZZ?eded[Z@dS)jr aYRepresentation of a specific locale. >>> locale = Locale('en', 'US') >>> repr(locale) "Locale('en', territory='US')" >>> locale.display_name u'English (United States)' A `Locale` object can also be instantiated from a raw locale string: >>> locale = Locale.parse('en-US', sep='-') >>> repr(locale) "Locale('en', territory='US')" `Locale` objects provide access to a collection of locale data, such as territory and language names, number and date format patterns, and more: >>> locale.number_symbols['decimal'] u'.' If a locale is requested for which no locale data is available, an `UnknownLocaleError` is raised: >>> Locale.parse('en_XX') Traceback (most recent call last): ... UnknownLocaleError: unknown locale 'en_XX' For more information see :rfc:`3066`. Nlanguager territory str | Nonescriptvariantmodifierr(rc||_||_||_||_||_d|_t |}|dd}tj |st|dS)abInitialize the locale object from the given identifier components. >>> locale = Locale('en', 'US') >>> locale.language 'en' >>> locale.territory 'US' :param language: the language code :param territory: the territory (country or region) code :param script: the script code :param variant: the variant code :param modifier: a modifier (following the '@' symbol, sometimes called '@variant') :raise `UnknownLocaleError`: if no locale data is available for the requested locale N@r) rrrrr _Locale__datar partitionrexistsr )rrrrrrridentifier_without_modifiers r%rzLocale.__init__s~2! "     YY &0&:&:3&?&?&B# !<== 1$Z00 0 1 1r$categoryaliasesMapping[str, str]cNt||}||S)afReturn the system default locale for the specified category. >>> for name in ['LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LC_MESSAGES']: ... os.environ[name] = '' >>> os.environ['LANG'] = 'fr_FR.UTF-8' >>> Locale.default('LC_MESSAGES') Locale('fr', territory='FR') The following fallbacks to the variable are always considered: - ``LANGUAGE`` - ``LC_ALL`` - ``LC_CTYPE`` - ``LANG`` :param category: one of the ``LC_XXX`` environment variable names :param aliases: a dictionary of aliases for locale identifiers )r)r parse)clsrr locale_strings r%defaultzLocale.defaults(,'xAAA yy'''r$_ preferred Iterable[str] availablesep Locale | Nonecht||||}|rt||SdS)a]Find the best match between available and requested locale strings. >>> Locale.negotiate(['de_DE', 'en_US'], ['de_DE', 'de_AT']) Locale('de', territory='DE') >>> Locale.negotiate(['de_DE', 'en_US'], ['en', 'de']) Locale('de') >>> Locale.negotiate(['de_DE', 'de'], ['en_US']) You can specify the character used in the locale identifiers to separate the different components. This separator is applied to both lists. Also, case is ignored in the comparison: >>> Locale.negotiate(['de-DE', 'de'], ['en-us', 'de-de'], sep='-') Locale('de', territory='DE') :param preferred: the list of locale identifiers preferred by the user :param available: the list of locale identifiers available :param aliases: a dictionary of aliases for locale identifiers )rrrN)r r r)rrrrrrs r% negotiatezLocale.negotiatesI6&i.5777  5<< <44 4 5 5r$Trstr | Locale | Noneresolve_likely_subtagsboolcTt|tr|St|tstd|t ||}t |}fdfd}|}||S|st |t|dkr |\}} } } } n |\}} } } d} td ||}td | pd | fd } td  | pd | } td  | pd | } | d krd} | dkrd} || | | | f}t |} td | }||t |}||Std |}|Ht |}t|dkr |\}}}}}n |\}}}}d}||| |||f}||St |)a*Create a `Locale` instance for the given locale identifier. >>> l = Locale.parse('de-DE', sep='-') >>> l.display_name u'Deutsch (Deutschland)' If the `identifier` parameter is not a string, but actually a `Locale` object, that object is returned: >>> Locale.parse(l) Locale('de', territory='DE') This also can perform resolving of likely subtags which it does by default. This is for instance useful to figure out the most likely locale for a territory you can use ``'und'`` as the language tag: >>> Locale.parse('und_AT') Locale('de', territory='AT') Modifiers are optional, and always at the end, separated by "@": >>> Locale.parse('de_AT@euro') Locale('de', territory='AT', modifier='euro') :param identifier: the locale identifier string :param sep: optional component separator :param resolve_likely_subtags: if this is specified then a locale will have its likely subtag resolved if the locale otherwise does not exist. For instance ``zh_TW`` by itself is not a locale that exists but Babel can automatically expand it to the full form of ``zh_hant_TW``. Note that this expansion is only taking place if no locale exists otherwise. For instance there is a locale ``en`` that can exist by itself. :raise `ValueError`: if the string does not appear to be a valid locale identifier :raise `UnknownLocaleError`: if no locale data is available for the requested locale :raise `TypeError`: if the identifier is not a string or a `Locale` z!Unexpected value for identifier: rc2 |S#t$rYdSwxYwN)r )partsrs r% _try_loadzLocale.parse.._try_loadBs6 sE{"%   tt s  cT|}||S|dd}||SdS)Nr#)rlocalers r%_try_load_reducingz(Locale.parse.._try_load_reducingHsIYu%%F! YuRaRy))F! "!r$NrrrrrZZZzzzr) isinstancer r TypeErrorrget_locale_identifierr lenr8r5)rrrrrinput_idrrrrrrrnew_id likely_subtagparts2 language2rscript2variant2 modifier2rs` @r%rz Locale.parsesf j& ) ) P J,, PN NNOO OZS111(//          5!!  M% /$X.. . u::??=B :Hi((38 0HiH01155hII23377 R)VVWXY ,--11&,BGG.//33GMr7KK   I V  F)VWh>'u--"#34488@@  $'' ](C(CDDF! ##34488BB  $!-00F6{{a=C: 1gx28/ 1gx ''IwR[(\]]F!  ***r$otherobjectc,dD]}t||sdS|jt|dkoc|jt|dkoJ|jt|dko1|jt|dko|jt|dkS)N)rrrrrFrrrrr)hasattrrgetattrrrrr)rrr's r%__eq__z Locale.__eq__sM  C5#&& uu  MWUJ77 7 8 Nge[99 9 8 K75(33 3 8 LGE955 5 8 MWUJ77 7  r$c.|| Sr)r)rrs r%__ne__z Locale.__ne__s;;u%%%%r$intc\t|j|j|j|j|jfSr)hashrrrrrrs r%__hash__zLocale.__hash__s.T]DNDK\4=233 3r$cdg}dD].}t||}|||d|/d|jd|dS)Nr)rrrr=zLocale(, ))rappendrr.)r parametersr'values r%__repr__zLocale.__repr__stT A 6 6CD#&&E !!S"4"45"4"4555BB$))J*?*?BBBBr$c\t|j|j|j|j|jfSr)rrrrrrrs r%__str__zLocale.__str__s/$dmT^&*k4<&*m&566 6r$localedata.LocaleDataDictc|j8tjtjt ||_|jSr)rrLocaleDataDictr4rrs r%_dataz Locale._datas4 ; $3JOCII4N4NOODK{r$rLocale | str | Nonec||}t|}|j|j}|r|js|js|jrg}|jr2||j |j|jr2||j |j|jr2||j |j|j r||j td|}|r|dd|dz }|S)aReturn the display name of the locale using the given locale. The display name will include the language, territory, script, and variant, if those are specified. >>> Locale('zh', 'CN', script='Hans').get_display_name('en') u'Chinese (Simplified, China)' Modifiers are currently passed through verbatim: >>> Locale('it', 'IT', modifier='euro').get_display_name('en') u'Italian (Italy, euro)' :param locale: the locale to use Nz (rr)r r languagesr5rrrrrscripts territoriesvariantsrfilterr.)rrretvaldetailss r%get_display_namezLocale.get_display_namesI >Ff%%!%%dm44  5t~ 5 5 5G{ @v~11$+>>???~ Gv155dnEEFFF| Bv224<@@AAA} .t}---T7++G 54tyy114444 r$a The localized display name of the locale. >>> Locale('en').display_name u'English' >>> Locale('en', 'US').display_name u'English (United States)' >>> Locale('sv').display_name u'svenska' :type: `unicode` )docc|||}t|}|j|jS)zReturn the language of this locale in the given locale. >>> Locale('zh', 'CN', script='Hans').get_language_name('de') u'Chinesisch' .. versionadded:: 1.0 :param locale: the locale to use )r rrr5rrrs r%get_language_namezLocale.get_language_names8 >Ff%%##DM222r$zx The localized language name of the locale. >>> Locale('en', 'US').language_name u'English' c||}t|}|j|jpdS)z.Return the territory name in the given locale.Nr)r rrr5rrs r%get_territory_namezLocale.get_territory_names; >Ff%%!%%dn&:;;;r$z The localized territory name of the locale if available. >>> Locale('de', 'DE').territory_name u'Deutschland' c||}t|}|j|jpdS)z+Return the script name in the given locale.Nr)r rrr5rrs r%get_script_namezLocale.get_script_names: >Ff%%~!!$+"3444r$z The localized script name of the locale if available. >>> Locale('sr', 'ME', script='Latn').script_name u'latinica' cF|tdS)zThe english display name of the locale. >>> Locale('de').english_name u'German' >>> Locale('de', 'DE').english_name u'German (Germany)' :type: `unicode`rI)rr rs r% english_namezLocale.english_names$$VD\\222r$c|jdS)zMapping of language codes to translated language names. >>> Locale('de', 'DE').languages['ja'] u'Japanisch' See `ISO 639 `_ for more information. rrrs r%rzLocale.languagessz+&&r$c|jdS)zMapping of script codes to translated script names. >>> Locale('en', 'US').scripts['Hira'] u'Hiragana' See `ISO 15924 `_ for more information. rrrs r%rzLocale.scripts+sz)$$r$c|jdS)zMapping of script codes to translated script names. >>> Locale('es', 'CO').territories['DE'] u'Alemania' See `ISO 3166 `_ for more information. rrrs r%rzLocale.territories7sz-((r$c|jdS)zMapping of script codes to translated script names. >>> Locale('de', 'DE').variants['1901'] u'Alte deutsche Rechtschreibung' rrrs r%rzLocale.variantsCz*%%r$c|jdS)aMapping of currency codes to translated currency names. This only returns the generic form of the currency name, not the count specific one. If an actual number is requested use the :func:`babel.numbers.get_currency_name` function. >>> Locale('en').currencies['COP'] u'Colombian Peso' >>> Locale('de', 'DE').currencies['COP'] u'Kolumbianischer Peso' currency_namesrrs r% currencieszLocale.currenciesNsz*++r$c|jdS)zMapping of currency codes to symbols. >>> Locale('en', 'US').currency_symbols['USD'] u'$' >>> Locale('es', 'CO').currency_symbols['USD'] u'US$' currency_symbolsrrs r%rzLocale.currency_symbols\sz,--r$c|jdS)zSymbols used in number formatting. .. note:: The format of the value returned may change between Babel versions. >>> Locale('fr', 'FR').number_symbols['decimal'] u',' number_symbolsrrs r%rzLocale.number_symbolsgsz*++r$c|jdS)zLocale patterns for decimal number formatting. .. note:: The format of the value returned may change between Babel versions. >>> Locale('en', 'US').decimal_formats[None] decimal_formatsrrs r%r zLocale.decimal_formatssz+,,r$c|jdS)aLocale patterns for compact decimal number formatting. .. note:: The format of the value returned may change between Babel versions. >>> Locale('en', 'US').compact_decimal_formats["short"]["one"]["1000"] compact_decimal_formatsrrs r%r zLocale.compact_decimal_formatssz344r$c|jdS)a{Locale patterns for currency number formatting. .. note:: The format of the value returned may change between Babel versions. >>> Locale('en', 'US').currency_formats['standard'] >>> Locale('en', 'US').currency_formats['accounting'] currency_formatsrrs r%rzLocale.currency_formatsz,--r$c|jdS)uLocale patterns for compact currency number formatting. .. note:: The format of the value returned may change between Babel versions. >>> Locale('en', 'US').compact_currency_formats["short"]["one"]["1000"] compact_currency_formatsrrs r%rzLocale.compact_currency_formatssz455r$c|jdS)zLocale patterns for percent number formatting. .. note:: The format of the value returned may change between Babel versions. >>> Locale('en', 'US').percent_formats[None] percent_formatsrrs r%rzLocale.percent_formatsr r$c|jdS)zLocale patterns for scientific number formatting. .. note:: The format of the value returned may change between Babel versions. >>> Locale('en', 'US').scientific_formats[None] scientific_formatsrrs r%rzLocale.scientific_formatssz.//r$c~ |jdddS#t$rtjicYSwxYw)zrLocale display names for day periods (AM/PM). >>> Locale('en', 'US').periods['am'] u'AM' day_periodsz stand-alonewide)rKeyErrorrrrs r%periodszLocale.periodssP 1:m,];FC C 1 1 1,R00 0 0 0 1s <<c|jdS)zLocale display names for various day periods (not necessarily only AM/PM). These are not meant to be used without the relevant `day_period_rules`. rrrs r%rzLocale.day_periodss z-((r$c\|jdtjiS)zCDay period rules for the locale. Used by `get_period_id`. day_period_rules)rr5rrrs r%rzLocale.day_period_ruless&z~~0*2KB2O2OPPPr$c|jdS)z{Locale display names for weekdays. >>> Locale('de', 'DE').days['format']['wide'][3] u'Donnerstag' daysrrs r%r z Locale.dayssz&!!r$c|jdS)zyLocale display names for months. >>> Locale('de', 'DE').months['format']['wide'][10] u'Oktober' monthsrrs r%r"z Locale.monthssz(##r$c|jdS)zLocale display names for quarters. >>> Locale('de', 'DE').quarters['format']['wide'][1] u'1. Quartal' quartersrrs r%r$zLocale.quartersrr$c|jdS)aLocale display names for eras. .. note:: The format of the value returned may change between Babel versions. >>> Locale('en', 'US').eras['wide'][1] u'Anno Domini' >>> Locale('en', 'US').eras['abbreviated'][0] u'BC' erasrrs r%r&z Locale.erassz&!!r$c|jdS)ucLocale display names for time zones. .. note:: The format of the value returned may change between Babel versions. >>> Locale('en', 'US').time_zones['Europe/London']['long']['daylight'] u'British Summer Time' >>> Locale('en', 'US').time_zones['America/St_Johns']['city'] u'St. John’s' time_zonesrrs r%r(zLocale.time_zonessz,''r$c|jdS)aLocale display names for meta time zones. Meta time zones are basically groups of different Olson time zones that have the same GMT offset and daylight savings time. .. note:: The format of the value returned may change between Babel versions. >>> Locale('en', 'US').meta_zones['Europe_Central']['long']['daylight'] u'Central European Summer Time' .. versionadded:: 0.9 meta_zonesrrs r%r*zLocale.meta_zonessz,''r$c|jdS)acPatterns related to the formatting of time zones. .. note:: The format of the value returned may change between Babel versions. >>> Locale('en', 'US').zone_formats['fallback'] u'%(1)s (%(0)s)' >>> Locale('pt', 'BR').zone_formats['region'] u'Hor\xe1rio %s' .. versionadded:: 0.9 zone_formatsrrs r%r,zLocale.zone_formats!sz.))r$c(|jddS)zThe first day of a week, with 0 being Monday. >>> Locale('de', 'DE').first_week_day 0 >>> Locale('en', 'US').first_week_day 6 week_data first_dayrrs r%first_week_dayzLocale.first_week_day1sz+&{33r$c(|jddS)zqThe day the weekend starts, with 0 being Monday. >>> Locale('de', 'DE').weekend_start 5 r. weekend_startrrs r%r2zLocale.weekend_start<sz+&77r$c(|jddS)zmThe day the weekend ends, with 0 being Monday. >>> Locale('de', 'DE').weekend_end 6 r. weekend_endrrs r%r4zLocale.weekend_endEsz+&}55r$c(|jddS)zThe minimum number of days in a week so that the week is counted as the first week of a year or month. >>> Locale('de', 'DE').min_week_days 4 r.min_daysrrs r% min_week_dayszLocale.min_week_daysNsz+&z22r$c|jdS)aJLocale patterns for date formatting. .. note:: The format of the value returned may change between Babel versions. >>> Locale('en', 'US').date_formats['short'] >>> Locale('fr', 'FR').date_formats['long'] date_formatsrrs r%r9zLocale.date_formatsXz.))r$c|jdS)uNLocale patterns for time formatting. .. note:: The format of the value returned may change between Babel versions. >>> Locale('en', 'US').time_formats['short'] >>> Locale('fr', 'FR').time_formats['long'] time_formatsrrs r%r<zLocale.time_formatsfr:r$c|jdS)a(Locale patterns for datetime formatting. .. note:: The format of the value returned may change between Babel versions. >>> Locale('en').datetime_formats['full'] u'{1}, {0}' >>> Locale('th').datetime_formats['medium'] u'{1} {0}' datetime_formatsrrs r%r>zLocale.datetime_formatstrr$c|jdS)aALocale patterns for formatting parts of a datetime. >>> Locale('en').datetime_skeletons['MEd'] >>> Locale('fr').datetime_skeletons['MEd'] >>> Locale('fr').datetime_skeletons['H'] datetime_skeletonsrrs r%r@zLocale.datetime_skeletonssz.//r$c|jdS)uLocale patterns for interval formatting. .. note:: The format of the value returned may change between Babel versions. How to format date intervals in Finnish when the day is the smallest changing component: >>> Locale('fi_FI').interval_formats['MEd']['d'] [u'E d. – ', u'E d.M.'] .. seealso:: The primary API to use this data is :py:func:`babel.dates.format_interval`. :rtype: dict[str, dict[str, list[str]]] interval_formatsrrs r%rBzLocale.interval_formatss(z,--r$r cB|jdtS)aPlural rules for the locale. >>> Locale('en').plural_form(1) 'one' >>> Locale('en').plural_form(0) 'other' >>> Locale('fr').plural_form(0) 'one' >>> Locale('ru').plural_form(100) 'many' plural_formrr5_default_plural_rulers r%rDzLocale.plural_formsz~~m-ABBBr$c|jdS)aPatterns for generating lists .. note:: The format of the value returned may change between Babel versions. >>> Locale('en').list_patterns['standard']['start'] u'{0}, {1}' >>> Locale('en').list_patterns['standard']['end'] u'{0}, and {1}' >>> Locale('en_GB').list_patterns['standard']['end'] u'{0} and {1}' list_patternsrrs r%rHzLocale.list_patternssz/**r$cB|jdtS)a?Plural rules for the locale. >>> Locale('en').ordinal_form(1) 'one' >>> Locale('en').ordinal_form(2) 'two' >>> Locale('en').ordinal_form(3) 'few' >>> Locale('fr').ordinal_form(2) 'other' >>> Locale('ru').ordinal_form(100) 'other' ordinal_formrErs r%rJzLocale.ordinal_formsz~~n.BCCCr$c|jdS)zLocalized names for various measurement systems. >>> Locale('fr', 'FR').measurement_systems['US'] u'am\xe9ricain' >>> Locale('en', 'US').measurement_systems['US'] u'US' measurement_systemsrrs r%rLzLocale.measurement_systemssz/00r$c|jdS)zThe text direction for the language. >>> Locale('de', 'DE').character_order 'left-to-right' >>> Locale('ar', 'SA').character_order 'right-to-left' character_orderrrs r%rNzLocale.character_ordersz+,,r$cpdd|jdDS)zThe text direction for the language in CSS short-hand form. >>> Locale('de', 'DE').text_direction 'ltr' >>> Locale('ar', 'SA').text_direction 'rtl' rc3&K|] }|dV dS)rNr#).0words r% z(Locale.text_direction..s&KK4tAwKKKKKKr$-)r.rNsplitrs r%text_directionzLocale.text_directions6wwKK4+?+E+Ec+J+JKKKKKKr$c|jdS)zDisplay names for units of measurement. .. seealso:: You may want to use :py:func:`babel.units.get_unit_name` instead. .. note:: The format of the value returned may change between Babel versions. unit_display_namesrrs r%rXzLocale.unit_display_namessz.//r$)NNNN) rrrrrrrrrrr(r)rrrrr(r ) rrrrrrrrr(r)rT)rrrrrrr(r )rrr(r)r(r)r(r)r(rr)rrr(r)r(r)r(r )Arrrrr classmethodLOCALE_ALIASESrrrrrrrrpropertyrr display_namer language_namerterritory_namer script_namerrrrrrrrr r rrrrrrrr r"r$r&r(r*r,r0r2r4r7r9r<r>r@rBrDrHrJrLrNrVrXr#r$r%r r sMD!%!"# '1'1'1'1'1R,0~(((([(0 %3 5555[5>'+ ++++[+B     &&&&3333CCCC6666 X !!!!!F8, 3    L 3 3 3 3 3H.5   M<<<<<X07   N55555(?1   K 3 3 3X 3 ' ' 'X ' % % %X % ) ) )X )&&&X& , , ,X ,...X. , , ,X , - - -X - 5 5 5X 5 . . .X . 6 6 6X 6 - - -X - 0 0 0X 0 1 1 1X 1)))X)QQQXQ """X"$$$X$&&&X& " " "X " ( ( (X ((((X(  * * *X *444X4888X8666X6333X3 * * *X * * * *X * . . .X . 0 0 0X 0...X.* C C CX C + + +X +DDDXD  1 1 1X 1---X-LLLXL 0 0 0X 0 0 0r$r rrrrcj|ddddf}td|D]}tj|}|r|dkrd|vr|dd}|ddd vrd }n|r ||vr||} t t |cS#t $rYwxYwdS) aReturns the system default locale for a given category, based on environment variables. >>> for name in ['LANGUAGE', 'LC_ALL', 'LC_CTYPE']: ... os.environ[name] = '' >>> os.environ['LANG'] = 'fr_FR.UTF-8' >>> default_locale('LC_MESSAGES') 'fr_FR' The "C" or "POSIX" pseudo-locales are treated as aliases for the "en_US_POSIX" locale: >>> os.environ['LC_MESSAGES'] = 'POSIX' >>> default_locale('LC_MESSAGES') 'en_US_POSIX' The following fallbacks to the variable are always considered: - ``LANGUAGE`` - ``LC_ALL`` - ``LC_CTYPE`` - ``LANG`` :param category: one of the ``LC_XXX`` environment variable names :param aliases: a dictionary of aliases for locale identifiers LANGUAGELC_ALLLC_CTYPELANGN:r.)CPOSIX en_US_POSIX)rr,getenvrUrr ValueError)rrvarnamesnamers r%r r s6*h FCHtX&&4  z!!cVmm c**1-||C  #~55& )Vw..  ,\&-A-ABBBBB     sB"" B/.B/rrrrrrcd|D}|D]}|}||vr|cS|rG||}|r0|d|}||vr|cS||}t |dkr&|d|vr |dcSdS)ulFind the best match between available and requested locale strings. >>> negotiate_locale(['de_DE', 'en_US'], ['de_DE', 'de_AT']) 'de_DE' >>> negotiate_locale(['de_DE', 'en_US'], ['en', 'de']) 'de' Case is ignored by the algorithm, the result uses the case of the preferred locale identifier: >>> negotiate_locale(['de_DE', 'en_US'], ['de_de', 'de_at']) 'de_DE' >>> negotiate_locale(['de_DE', 'en_US'], ['de_de', 'de_at']) 'de_DE' By default, some web browsers unfortunately do not include the territory in the locale identifier for many locales, and some don't even allow the user to easily add the territory. So while you may prefer using qualified locale identifiers in your web-application, they would not normally match the language-only locale sent by such browsers. To workaround that, this function uses a default mapping of commonly used language-only locale identifiers to identifiers including the territory: >>> negotiate_locale(['ja', 'en_US'], ['ja_JP', 'en_US']) 'ja_JP' Some browsers even use an incorrect or outdated language code, such as "no" for Norwegian, where the correct locale identifier would actually be "nb_NO" (Bokmål) or "nn_NO" (Nynorsk). The aliases are intended to take care of such cases, too: >>> negotiate_locale(['no', 'sv'], ['nb_NO', 'sv_SE']) 'nb_NO' You can override this default mapping by passing a different `aliases` dictionary to this function, or you can bypass the behavior althogher by setting the `aliases` parameter to `None`. :param preferred: the list of locale strings preferred by the user :param available: the list of locale strings available :param sep: character that separates the different parts of the locale strings :param aliases: a dictionary of aliases for locale identifiers c:g|]}||Sr#)lower)rQas r% z$negotiate_locale..as%333q3333r$rrN)rpr5replacerUr)rrrrrllaliasrs r%r r 3s\43I333I   \\^^ ??MMM  !KKOOE ! c3//;;==I-- LLL S!! u::>>eAhnn..);;8OOO 4r$rktuple[str, str | None, str | None, str | None] | tuple[str, str | None, str | None, str | None, str | None]c|d\}}}d|vr|ddd}||}|d}|st d|dx}x}}|rZt |ddkrA|dr'|d}|rt |ddkrB|dr(|d}nHt |dd kr/|d r|d}|rt |ddkr |dd s9t |dd krF|ddr&|}|rt |d |r|||||fS||||fS) aParse a locale identifier into a tuple of the form ``(language, territory, script, variant, modifier)``. >>> parse_locale('zh_CN') ('zh', 'CN', None, None) >>> parse_locale('zh_Hans_CN') ('zh', 'CN', 'Hans', None) >>> parse_locale('ca_es_valencia') ('ca', 'ES', None, 'VALENCIA') >>> parse_locale('en_150') ('en', '150', None, None) >>> parse_locale('en_us_posix') ('en', 'US', None, 'POSIX') >>> parse_locale('it_IT@euro') ('it', 'IT', None, None, 'euro') >>> parse_locale('it_IT@custom') ('it', 'IT', None, None, 'custom') >>> parse_locale('it_IT@') ('it', 'IT', None, None) The default component separator is "_", but a different separator can be specified using the `sep` parameter. The optional modifier is always separated with "@" and at the end: >>> parse_locale('zh-CN', sep='-') ('zh', 'CN', None, None) >>> parse_locale('zh-CN@custom', sep='-') ('zh', 'CN', None, None, 'custom') If the identifier cannot be parsed into a locale, a `ValueError` exception is raised: >>> parse_locale('not_a_LOCALE_String') Traceback (most recent call last): ... ValueError: 'not_a_LOCALE_String' is not a valid locale identifier Encoding information is removed from the identifier, while modifiers are kept: >>> parse_locale('en_US.UTF-8') ('en', 'US', None, None) >>> parse_locale('de_DE.iso885915@euro') ('de', 'DE', None, None, 'euro') See :rfc:`4646` for more information. :param identifier: the locale identifier string :param sep: character that separates the different components of the locale identifier :raise `ValueError`: if the string does not appear to be a valid locale identifier rrfrsrzexpected only letters, got Nrrz! is not a valid locale identifier) rrUpoprpisalpharkrtitleupperisdigit) rrrrrlangrrrs r%rrrsDt)22377J8 j%%c1--a0   S ! !E 99Q<<    D <<>>A?t??@@@#''F'Y &U1X!##a(8(8(:(:#1##%% % uQx==A  %("2"2"4"4  ! **,,II q]]a  E!H$4$4$6$6  ! I & E!H uQx{2244 E!H uQx{2244))++##%% MJKKKLLL0Y99Y//r$tuptuple[str] | tuple[str, str | None] | tuple[str, str | None, str | None] | tuple[str, str | None, str | None, str | None] | tuple[str, str | None, str | None, str | None, str | None]c t|dd}|ddt|z zz\}}}}}|td||||f}|r|d|n|S)a,The reverse of :func:`parse_locale`. It creates a locale identifier out of a ``(language, territory, script, variant, modifier)`` tuple. Items can be set to ``None`` and trailing ``None``\s can also be left out of the tuple. >>> get_locale_identifier(('de', 'DE', None, '1999', 'custom')) 'de_DE_1999@custom' >>> get_locale_identifier(('fi', None, None, None, 'custom')) 'fi@custom' .. versionadded:: 1.0 :param tup: the tuple as returned by :func:`parse_locale`. :param sep: the separator for the identifier. Nrrr)tuplerr.r)rrrrrrrrets r%rrs}. BQB..C14w!c#hh,7O1O.D)VWh ((6$vy' BCC D DC"* 3c  H   3r$)r'rr(r))rrrrr(r) rrrrrrrrr(r)r)rrrrr(rw)rrrrr(r)!r __future__rr,r3collections.abcrrtypingrrbabelr babel.pluralr __all__typing_extensionsrrr__annotations__r rFr&r8rZrr r r r rrr#r$r%rs#""""" --------%%%%%%%%######   A44444444$ K"A@@@ !z"~~222+%+%+%+%\ '  "& 15w @Dg '  "& 15w @Dg  '  #' 26w AEg  '   #' 26w AEg   '    #'  26w  AEg   '    #'  26w  AEg  '  #' 26w  GN w    % % % % % % % % ~ 0~ 0~ 0~ 0~ 0~ 0~ 0~ 0B+/^*****ZUXwE<<<<<B[0[0[0[0[0H 4444444r$