6

API object User has property language_code - how do Telegram determine user's language, and how do I change it?

I wish to create response for user based on language_code language, but I am not sure I can trust this value, because fore example my language_code is 'en', but for the chatting or UI I am using another one!

wowkin2
  • 5,895
  • 5
  • 23
  • 66
Valera Kvip
  • 334
  • 5
  • 14

1 Answers1

5

Each Update from Telegram contains User information (in Message, in InlineQuery or some other). This language_code is based on which language is set as default on user's device or set for Telegram app. You can trust it.

But some users may want to change a language just for your bot. For that you can add your custom "Settings" to your bot menu, with all languages you support.

wowkin2
  • 5,895
  • 5
  • 23
  • 66