U su]aøã@s¤dZddlZddlZddlmZdddddgZde ¡iZ eƒZ d d iZ d d „Z d d„Z ddd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zedœdd„ZdS)z*Activate, get and deactivate translations.éN)ÚlocalÚactivateÚ deactivateÚgettextÚngettextÚthousands_separatorZfr_FRú cCsBz&tdkrWdStj tj t¡d¡WStk r<YdSXdS)NÚlocale)Ú__file__ÚosÚpathÚjoinÚdirnameÚ NameError©rrú>/opt/alt/python38/lib/python3.8/site-packages/humanize/i18n.pyÚ_get_default_locale_paths rc Cs2z ttjWSttfk r,tdYSXdS)N)Ú _TRANSLATIONSÚ_CURRENTr ÚAttributeErrorÚKeyErrorrrrrÚget_translations rcCsL|dkrtƒ}|dkrtdƒ‚|tkr>t d||g¡}|t|<|t_t|S)aRActivate internationalisation. Set `locale` as current locale. Search for locale in directory `path`. Args: locale (str): Language name, e.g. `en_GB`. path (str): Path to search for locales. Returns: dict: Translations. Raises: Exception: If humanize cannot find the locale folder. NznHumanize cannot determinate the default location of the 'locale' folder. You need to pass the path explicitly.Zhumanize)rÚ ExceptionrÚgettext_moduleÚ translationrr )r r rrrrr"sÿcCs dt_dS)z Deactivate internationalisation.N)rr rrrrr@scCs tƒ |¡S)zvGet translation. Args: message (str): Text to translate. Returns: str: Translated text. )rr©ÚmessagerrrrEs cCsRztƒ ||¡WStk rL|d|}tƒ |¡}||krD|n|YSXdS)a Fetches a particular translation. It works with `msgctxt` .po modifiers and allows duplicate keys with different translations. Args: msgctxt (str): Context of the translation. message (str): Text to translate. Returns: str: Translated text. úN)rÚpgettextrr)ZmsgctxtrÚkeyrrrrrQs   rcCstƒ |||¡S)a5Plural version of gettext. Args: message (str): Singular text to translate. plural (str): Plural text to translate. num (str): The number (e.g. item count) to determine translation for the respective grammatical number. Returns: str: Translated text. )rr)rÚpluralZnumrrrrjs cCs|S)a^Mark a string as a translation string without translating it. Example usage: ```python CONSTANTS = [gettext_noop('first'), gettext_noop('second')] def num_name(n): return gettext(CONSTANTS[n]) ``` Args: message (str): Text to translate in the future. Returns: str: Original text, unchanged. rrrrrÚ gettext_noopysr!cCs||fS)aÉMark two strings as pluralized translations without translating them. Example usage: ```python CONSTANTS = [ngettext_noop('first', 'firsts'), ngettext_noop('second', 'seconds')] def num_name(n): return ngettext(*CONSTANTS[n]) ``` Args: singular (str): Singular text to translate in the future. plural (str): Plural text to translate in the future. Returns: tuple: Original text, unchanged. r)Zsingularr rrrÚ ngettext_noopŒsr")Úreturnc Cs0zttj}Wnttfk r*d}YnX|S)ztReturn the thousands separator for a locale, default to comma. Returns: str: Thousands separator. ú,)Ú_THOUSANDS_SEPARATORrr rr)Úseprrrr s  )N)Ú__doc__rrZos.pathr Z threadingrÚ__all__ZNullTranslationsrrr%rrrrrrr!r"ÚstrrrrrrÚs&  ÿ