code4moldova / voluntar-telegram-client

Telegram bot that connects volunteers to beneficiaries who need assistance during the COVID-19 pandemic
3 stars 0 forks source link

Add RU translation for chat bot #37

Open mihaelataranu7 opened 4 years ago

mihaelataranu7 commented 4 years ago

@Junumboxo can you please help with the translation of tg bot messages?

Junumboxo commented 4 years ago

yep, need the original text and the file for the translation

ralienpp commented 4 years ago

This is a duplicate of #23.

At the moment the bottleneck is not in the lack of strings, but in the "how to structure the code?" decision. @popovvasile, you mentioned earlier that you've added this to chat bots in the past - can you provide an example of how you got it done? Did you use an existing l10n library, or roll out your own solution?

popovvasile commented 4 years ago
req = request.Request(con_pool_size=8)
bot_obj = Bot(token=token, request=req)

with open('languages.json') as f:
    lang_dicts = json.load(f)
if lang == "ENG":
    Bot.lang_dict = lang_dicts["ENG"]
else:
    Bot.lang_dict = lang_dicts["RUS"]
updater = tg.Updater(use_context=True, bot=bot_obj)
popovvasile commented 4 years ago

@ralienpp In cazul nostru lucreaza asa ca fiecare bot are propria limba. Insa poti face asa ca fiecare user sa aiba propria limba. Poti salva orice dict in Bot.lang_dict, de ex. ceva de genu

Bot.lang_dict={"RUS":{"string_1":"Привет"},
                 "ROM":{"string_1":"Salut"}}

Si pe urma in baza la user_id scoti stringul de care ai nevoie.

user_lang = find_one(user_id=update.user.id)["lang"]
bot.lang_string["RUS"]["string_1"]

Nu-i super eficient, dar e ceva