nickoala / telepot

Python framework for Telegram Bot API
MIT License
2.43k stars 474 forks source link

i18n + telepot? #250

Open b0g3r opened 7 years ago

b0g3r commented 7 years ago

I use flask-babel for message internationalization. With gettext() my messages localized when i'm imported my message.py, and i decided use lazy_gettext() (this function returns lazy-object, which localized when calls str()), but in Bot.sendMessage and other methods nowhere called str() with argument. May be added to the module str-wrapping?

b0g3r commented 7 years ago

For example: https://github.com/b0g3r/flask_i18n_tg_bot/blob/master/tg_bot/main.py if in this code replace gettext with lazy_gettext, then i get an error:

 File "main.py", line 44, in handler
    bot.sendMessage(id, message)
  File "C:\Users\b0\venvs\sel-bot\lib\site-packages\telepot\__init__.py", line 408, in sendMessage
    return self._api_request('sendMessage', _rectify(p))
  File "C:\Users\b0\venvs\sel-bot\lib\site-packages\telepot\__init__.py", line 397, in _api_request
    return api.request((self._token, method, params, files), **kwargs)
  File "C:\Users\b0\venvs\sel-bot\lib\site-packages\telepot\api.py", line 130, in request
    r = fn(*args, **kwargs)  # `fn` must be thread-safe
  File "C:\Users\b0\venvs\sel-bot\lib\site-packages\urllib3\request.py", line 138, in request_encode_body
    body, content_type = encode_multipart_formdata(fields, boundary=multipart_boundary)
  File "C:\Users\b0\venvs\sel-bot\lib\site-packages\urllib3\filepost.py", line 86, in encode_multipart_formdata
    body.write(data)