OfficeDev / teams-toolkit

Developer tools for building Teams apps
Other
434 stars 171 forks source link

Implementation of Translation in Teams Bot adaptive cards #11843

Open IAM5K opened 2 weeks ago

IAM5K commented 2 weeks ago

Is your feature request related to a problem? Please describe. Our product is live on store and we got some users from different countries preferring to use the app in their preferred language. We are continuously getting requests to implement translations.

Describe the solution you'd like Solutions i am looking for:

  1. Is there an existing way or method for translation
  2. If not what approach should we prefer so that we don't mess up with optimization and the accuracy of translations

Describe alternatives you've considered Our known approaches:

  1. Based on user preferred language, use en.json, italian.json, etc.
  2. Use google translation api and dynamically populate all adaptive cards.

Additional context Add any other context or screenshots about the feature request here.

IAM5K commented 2 weeks ago

https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/build-and-test/apps-localization

Found a relevant way of bot localisation. Please review this once if you have any suggestions or updates to this.

We can close this issue if you have nothing to add.

HuihuiWu-Microsoft commented 1 week ago

Hi @IAM5K, sorry that my last reply seems have been swallowed due to network issue. We don't have preference on the way to localize your adaptive cards, please choose either way according to your needs.

IAM5K commented 1 week ago

Thanks for the info, @HuihuiWu-Microsoft

I would like to ask one more question please.

In direct to bot /personal conversation with bot we can smoothly handle the localisation but is the same possible when the app is added in 1:1 conversation of Alice and Bob where Alice prefers English and Bob prefers Italian. Is there a way or parameters in adaptive cards to have both language strings as parameters to be binded/passed to card and users can see the same translated card based on preference.

Please let me know if you are able to understand the scenario. Feel free to revert back if you have any doubts

HuihuiWu-Microsoft commented 1 week ago

Hi @IAM5K, I'm trying to understand your question. In 1:1 conversation of Alice and Bob, when one of them interact with bot, bot will send localized replies to user based on user locale. Why both language strings are needed to be passed? Could you describe more about your scenario?

IAM5K commented 1 week ago

Lets take a scenario, we are making a meeting / note taking bot. Where either Alice or Bob give command @botName note: This a sample string to keep notes.

After taking notes bot send a acknowledgement card that is common for both. When Alice is using teams app in Italian they can see the same card in their preferred language.

HuihuiWu-Microsoft commented 1 week ago

@IAM5K You can always send localized contents based on user's locale. But the questions is how to get each member's(Alice and Bob) locale. In the existing localization sample(https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/app-localization/nodejs), the locale is obtained from turnContext.activity which is for current text field. But I don't see any API for getting locale of each member in groupchat or channel.

BTW, user might be able to set following translation settings in Teams to get messages with desired locale. image

IAM5K commented 1 week ago

We can use graph api to extract members details. Then update the values for language strings for each.

What I am trying to explore is how one single card can be made capable of showing itself in different languages

HuihuiWu-Microsoft commented 1 week ago

That's OK if you use Graph API though the locale info might not the same with Teams settings.

I don't quite understand: it should be the same with what you do for personal conversation with bot as long as you obtained the locale for each member. Just pass the locale and get localized content, then send the card.

IAM5K commented 1 week ago

I will implement this and then get back if there is any issue.