Guest User

Untitled

a guest
Oct 26th, 2019
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.24 KB | None | 0 0
  1. @dp.message_handler(lambda m: m.from_user.id in admins, content_types=['document'])
  2. async def change_localization(m):
  3.     name = m.document.file_name
  4.     if name == 'ru_RU.po':
  5.         f = await bot.get_file(m.document.file_id)
  6.         print(f)
  7.         print(f'https://api.telegram.org/file/bot{API_TOKEN}{f.file_path}')
  8.         r = requests.get(f'https://api.telegram.org/file/bot{API_TOKEN}/{f.file_path}')
  9.         print(r)
  10.         print(r.content)
  11.         with open('./locale/ru/LC_MESSAGES/ru_RU.po', 'wb') as file:
  12.             file.write(r.content)
  13.         print('Ready')
  14.         print(os.path.abspath("./locale/ru/LC_MESSAGES/ru_RU.po"))
  15.         Popen(["python", "C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python37-32\\Tools\\i18n\\msgfmt.py", "./locale/ru/LC_MESSAGES/ru_RU.po"],
  16.               stdout=sys.stdout).communicate()
  17.         gettext.install('ru_RU', './locale')
  18.         print('Good to go')
  19.  
  20.         #еще пробовал так:
  21.         gettext_windows.setup_env()
  22.         locale.setlocale(locale.LC_ALL, '')
  23.         gettext.install('ru_RU', './locale')
  24.        
  25.         #и так:
  26.         t = gettext.translation('ru_Ru', './locale')
  27.         global _
  28.         _ = t.gettext
  29.  
  30.         #и еще так:
  31.         os.execle(sys.executable, sys.executable, *sys.argv)
Add Comment
Please, Sign In to add comment