NS@sFddlZddlZddlZddddZddZdS)NTc CsJxC|D];}tjdddtjj|}d}tjj|rtj|tjrt|}xv|D]n} | j } |r| j |rd}|} n| r| |krd}|} n|j | j dqtWWdQXn| r|r|j |j dn|j tj|j|tj|dqWdS)zY find all strings that startswith findString and replace them with setString ZdeleteFdirTzUTF-8Ni)tempfileZNamedTemporaryFileospathdirnameexistsaccessR_OKopenstrip startswithwriteencodeflushrenamenamechmod) Z findStringZ setStringZ file_listr appendfnameoutZ foundStringflineZtmpr8/usr/lib/python3/dist-packages/LanguageSelector/utils.pyfind_string_and_replace s*     #  rcCs8|jdd}tjd|gdd}|jS)z9 generate locale name for LC_* environment variables :rz)/usr/share/language-tools/language2localeZuniversal_newlinesT)split subprocessZ check_outputrstrip)ZlanguageZ first_elemZlocalerrrlanguage2locale)s   r)rrrrrrrrrs