File: //lib64/python3.6/site-packages/tornado/__pycache__/locale.cpython-36.opt-1.pyc
3
��fQ � @ s d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl m
Z
ddlmZ ddl
mZmZmZmZ dai aetg�adad Zed
d�dd
�Zedd�dd�Zdeedd�dd�Zeedd�dd�Zee d�dd�ZG dd
� d
e�ZG dd� de�Z G dd� de�Z!dS ) a� Translation methods for generating localized strings.
To load a locale and generate a translated string::
user_locale = tornado.locale.get("es_LA")
print(user_locale.translate("Sign out"))
`tornado.locale.get()` returns the closest matching locale, not necessarily the
specific locale you requested. You can support pluralization with
additional arguments to `~Locale.translate()`, e.g.::
people = [...]
message = user_locale.translate(
"%(list)s is online", "%(list)s are online", len(people))
print(message % {"list": user_locale.list(people)})
The first string is chosen if ``len(people) == 1``, otherwise the second
string is chosen.
Applications should call one of `load_translations` (which uses a simple
CSV format) or `load_gettext_translations` (which uses the ``.mo`` format
supported by `gettext` and related tools). If neither method is called,
the `Locale.translate` method will simply return the original string.
� N)�escape)�gen_log)�LOCALE_NAMES)�Iterable�Any�Union�Dict�en_USF��Locale)�locale_codes�returnc G s
t j| � S )a� Returns the closest match for the given locale codes.
We iterate over all given locale codes in order. If we have a tight
or a loose match for the code (e.g., "en" for "en_US"), we return
the locale. Otherwise we move to the next code in the list.
By default we return ``en_US`` if no translations are found for any of
the specified locales. You can change the default locale with
`set_default_locale()`.
)r �get_closest)r � r �/usr/lib64/python3.6/locale.py�get? s r )�coder
c C s | a tttj� �t g �adS )a7 Sets the default locale.
The default locale is assumed to be the language used for all strings
in the system. The translations loaded from disk are mappings from
the default locale to the destination locale. Consequently, you don't
need to create a translation file for the default locale.
N)�_default_locale� frozenset�list�
_translations�keys�_supported_locales)r r r r �set_default_localeM s
r )� directory�encodingr
c C s� i a �xntj| �D �]^}|jd�s$q|jd�\}}tjd|�sXtjd|tj j
| |�� qtj j
| |�}|dkr�t|d��}|jt
tj��}W dQ R X |tjtjfkr�d}nd}t||d ���}i t |<