%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/LanguageSelector/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/LanguageSelector/__pycache__/LocaleInfo.cpython-312.pyc

�

k�!fA2���ddlmZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddlmZ
ddlmZGd�de�Zed	k(r�d
Zede�Zedej-�z�ed
ej/�z�eej0�eej2�eej4�eej7��yy)�)�print_function)�absolute_importN)�macros)�gettext)�ElementTreec�Z�eZdZdZdgZd�Zd�Zd�Zd�Zd�Z	d�Z
dd	�Zd
�Zd�Z
d�Zd
�Zy)�
LocaleInfoz< class with handy functions to parse the locale information z/etc/default/localec�*�||_tjj|d|�}i|_i|_i|_td��}|jd�}|D]k}d|jvr|jd}n|jd}d|jvr|jd}n|jd}||j|<�mtd	�|jd
<td�|jd<td
��}|jd�}|D]k}d|jvr|jd}	n|jd}	d|jvr|jd}n|jd}|	|j
|<�mt|�5}
|
D]f}|j�}|jd�s|dk(r�*|jd�}
|
djd�}d|
dz|j|d<�h	ddd�y#1swYyxYw)N�dataz&/usr/share/xml/iso-codes/iso_639_3.xml)�file�iso_639_3_entry�common_name�name�
part1_code�idzChinese (simplified)zzh-hanszChinese (traditional)zzh-hantz%/usr/share/xml/iso-codes/iso_3166.xml�iso_3166_entry�alpha_2_code�alpha_3_code�#��;��:z%sr)�_datadir�os�path�join�_lang�_country�
_languagelistr�iter�attrib�_�open�strip�
startswith�split)�self�languagelist_file�datadir�LANGUAGELIST�et�it�elm�lang�code�descr�f�line�tmp�w�	localeenvs               �=/usr/lib/python3/dist-packages/LanguageSelector/LocaleInfo.py�__init__zLocaleInfo.__init__s����
��w�w�|�|�G�V�5F�G����
���
� ����F�
G��
�W�W�&�
'���		$�C���
�
�*��z�z�-�0���z�z�&�)���s�z�z�)��z�z�,�/���z�z�$�'��#�D�J�J�t��		$�!"�"8� 9��
�
�9�� !�"9� :��
�
�9���E�
F��
�W�W�%�
&���		(�C���
�
�*��
�
�=�1���
�
�6�*������+��z�z�.�1���z�z�.�1��"'�D�M�M�$��		(��,�
�
	?�1��
?���j�j�l���>�>�#�&�#��)���I�I�c�N���a�D�J�J�s�O�	�37�!�A�$�;��"�"�9�Q�<�0�
?�
	?�
	?�
	?�s
�A,H	�	Hc�>�||jvr|j|Sy)z$ map language code to language name r)r�r(r0s  r7r/zLocaleInfo.lang[s ���4�:�:���:�:�d�#�#��c�>�||jvr|j|Sy)z! map country code to country namer)rr:s  r7�countryzLocaleInfo.countryas ���4�=�=� ��=�=��&�&�r;c�h�g}tjddgtjd��}|j�dj	d�D]b}|j�}|j
d�dkr�(tj|j|�}|d}||vs�R|j|��d|S)	zR return a list of locales available on the system
            (running locale -a) �localez-aT)�stdout�universal_newlinesr�
z.utf8�LOCALE)�
subprocess�Popen�PIPE�communicater'r%�findr�LangpackMacrosr�append)r(�locales�pr3r4�macrr?s       r7�generated_localeszLocaleInfo.generated_localesgs��������h��-�j�o�o�04�
6���M�M�O�A�&�,�,�T�2�	'�D��*�*�,�C��x�x�� �1�$���(�(�����<�D��(�^�F��W�$����v�&�	'��r;c���||jvrZtjd|j|�}||j|k(r#tjd|j|�}|S|S)zreturn translated language�iso_639�	iso_639_3)rr�dgettext)r(r/�	lang_names   r7�translate_languagezLocaleInfo.translate_languageys`���4�:�:���(�(��D�J�J�t�4D�E�I��D�J�J�t�,�,�#�,�,�[�$�*�*�T�:J�K�	����Kr;c�l�||jvr%tjd|j|�}|S|S)z�
        return translated language and country of the given
        locale into the given locale, e.g. 
        (Deutsch, Deutschland) for de_DE
        �iso_3166)rrrR)r(r=�country_names   r7�translate_countryzLocaleInfo.translate_country�s6�� �d�m�m�#�"�+�+�J��
�
�g�8N�O�L����Nr;c��d}tj|j|�}|dk(r=d}dtjvrtjd}|dtjd<|j|d�}|}t
|d�dkDr||j|d�}|j�D�	cgc]}	|	j|d�s�|	��}
}	|d	k(rt
|
�d
kDs|dk(r|j|d�}|r|�d|�d�}t
|d
�dkDr
|�d|d
��}|dk(r(r|tjd<|Stjd=|Scc}	w)z4 get a locale code and output a human readable name rTN�LANGUAGErC�LCODE�CCODErF�z (�)�VARIANTz - )rrIrr�environrT�lenrXrNr&r=)r(r?�native�allCountries�	returnValrM�current_languagerSrW�k�l�	mycountrys            r7�	translatezLocaleInfo.translate�sQ���	��$�$�T�]�]�F�;���T�>�#���R�Z�Z�'�#%�:�:�j�#9� �%)�(�^�B�J�J�z�"��+�+�D��M�:�	��	��t�G�}���!��1�1�$�w�-�@�L� �2�2�4�T�q����T�'�]�8S��T�A�T���%�#�a�&�1�*���9M� �L�L��g��7�	��-6�� E�I��t�I���!�#�%.��Y��@�I��T�>��)9��
�
�:�&����J�J�z�*����Us�2E�Ec���|sytj|j|�}|d}|d}||jvr|j|}n||k(r|}n|�d|��}|j	d�s
|dk(sd|z}|S)z� input is a language code, output a string that can be put in
            the LANGUAGE enviroment variable.
            E.g: en_DK -> en_DK:en
        rr[rCrz:en�enz%s:en)rrIrr �endswith)r(r0rM�langcoder?�langlists      r7�
makeEnvStringzLocaleInfo.makeEnvString�s���
���$�$�T�]�]�D�9����=���h����T�'�'�'��)�)�&�1�H�
�x�
��H�"(�(�3�H��!�!�%�(�H��,<���)�H��r;c��d}d}g}tjjd�}tjj|�rjtj|tj
�rFt
|�5}|D],}tjd|�}|s�|jd�}�.	ddd�tjtj��j}	tj�}	|	j!dd�}
tj"|
d��}|j%|�}|	j!d|�}
tj"|
d��}|j'd	d
�}t)|�dk(r#|j'd	d�}
|j+|
�}t)|�dk(r%d
tj4vrtj4d
}t)|�dk(r%dtj4vrtj4d}t)|�dk(r%dtj4vrtj4d}t)|�dkDrt)|�dk(r|j+|�}|j7|�|j7|�|S#1swY���xYw#t,$r-}t/j0|j2d�Yd}~��(d}~wwxYw)Nrz~/.pam_environmentzLANGUAGE(\s+DEFAULT)?=(.*)$�zorg.freedesktop.Accountsz/org/freedesktop/Accounts)�dbus_interfacezorg.freedesktop.DBus.Propertieszorg.freedesktop.Accounts.User�
FormatsLocaler�LanguagerZ�LC_NAME�LANG)rr�
expanduser�exists�access�R_OKr$�re�match�group�pwd�getpwuid�geteuid�pw_name�dbus�	SystemBus�
get_object�	Interface�FindUserByName�Getraro�	Exception�warnings�warn�argsr`rJ)r(�formats�language�result�fnamer2r3�match_language�	user_name�bus�obj�iface�	user_path�
firstLanguage�msgs               r7�getUserDefaultLanguagez!LocaleInfo.getUserDefaultLanguage�s7�����������"�"�#7�8��
�7�7�>�>�%� �
�9�9�U�B�G�G�$��e��
;���;�D�%'�X�X�.L�T�%R�N�%�#1�#7�#7��#:��;�
;�
�L�L�����.�6�6�	�	��.�.�"�C��.�.�!;�=X�Y�C��N�N�3�7Q�R�E��,�,�Y�7�I��.�.�!;�Y�G�C��N�N�3�7X�Y�E��i�i� ?��Q�G��8�}��!� %�	�	�*I�:� V�
��-�-�m�<��
�x�=�A��*��
�
�":��z�z�*�-�H��w�<�1���b�j�j�!8��j�j��+�G��w�<�1���2�:�:�!5��j�j��(�G��w�<�!���H�
�� 2��)�)�'�2�H��
�
�g���
�
�h���
�A
;�
;��$�	��M�M�#�(�(�1�+�&���	�s+�4J�J�!B:J�J�	K�"K�Kc��d}d}d}g}|jD�]I}tjj|�s�$tj|tj
�s�It
|�5}|D]�}|jd�r|jdd�}tjd|�}|r|jd�}|jd�r|jdd�}tjd|�}	|	r|	jd�}|jd�r|jdd�}tjd	|�}
|
s��|
jd�}��	ddd���Lt|�d
k(rd}t|�d
k(r|j|�}t|�d
k(r|}|j|�|j|�|S#1swY���xYw)Nrrv�"z
LANG=(.*)$r]�LC_TIMEz
LC_TIME=(.*)$rZzLANGUAGE=(.*)$rzen_US.UTF-8)�environmentsrrrxryrzr$r&�replacer{r|r}rarorJ)r(r/r�r�r�r�r2r3�
match_lang�
match_formatsr�s           r7�getSystemDefaultLanguagez#LocaleInfo.getSystemDefaultLanguages������������&�&�	?�E��w�w�~�~�e�$��y�y�����(��%�[�?�A� !�?���?�?�6�2�#'�<�<��B�#7�D�%'�X�X�m�D�%A�
�%�#-�#3�#3�A�#6�D��?�?�9�5�#'�<�<��B�#7�D�(*���1A�$�(G�
�(�&3�&9�&9�!�&<�G��?�?�:�6�#'�<�<��B�#7�D�)+���2C�D�)I��)�'5�';�';�A�'>�H�!?�?�?�	?�*�t�9��>� �D��x�=�A���)�)�$�/�H��w�<�1���G��
�
�g���
�
�h���
�9?�?�s�)CG�G�G	c��tj|jdtj�syt	|jd�5}|D]}|jd�s�ddd�y	ddd�y#1swYyxYw)NrFzLC_TIME=T)rryr�rzr$r&)r(r2r3s   r7�isSetSystemFormatszLocaleInfo.isSetSystemFormats2sy���y�y��*�*�1�-�r�w�w�7��
�$�#�#�A�&�
'�	 �1��
 ���?�?�:�.��	 �	 �
 �	 ��		 ��s�A8�#A8�-A8�8BN)FF)�__name__�
__module__�__qualname__�__doc__r�r8r/r=rNrTrXriror�r�r��r;r7r	r	sH��B�)�*�L�??�B���$��6�^�,'�R$�Lr;r	�__main__z/usr/share/language-selector/�languagelistz)default system locale and languages: '%s'z'default user locale and languages: '%s')�
__future__rrr{rDrrr~�sysr�r��LanguageSelectorrr#�xml.etree.ElementTreer�objectr	r�r*�li�printr�r�rrr rNr�r;r7�<module>r�s���
&�&�	���	�
�
���#� �-�c��c�L	�z��-�G�	�N�G�	,�B�	�
5��8S�8S�8U�
U�V�	�
3�b�6O�6O�6Q�
Q�R�	�"�(�(�O�	�"�+�+��	�"�
�
��	�"�
�
�
 �!�r;

Zerion Mini Shell 1.0