'How to get MS Teams (Desktop App) language programmatically?

Using a Desktop Teams application. Based on the language set in the Teams application, want to show customized content to users through my EXE written in C#.

  1. Is there a way to obtain the Language of the teams through a program or any open source library which works reliably?
  2. Or, is it always stored in a specific location like a registry or file which can be read or parsed?

Because Teams load translations even when the internet is not available unless it stores them based on the language chosen when on the internet.



Solution 1:[1]

There is no API available to read locale(Language) information from Microsoft teams. But You can get the same in following ways:

  1. If it bot application, you can get from turncontext.activity: https://docs.microsoft.com/en-us/dotnet/api/microsoft.bot.builder.turncontext.locale?view=botbuilder-dotnet-stable

  2. If it is tab application, you can get locale from context of your tab: https://docs.microsoft.com/en-us/microsoftteams/platform/tabs/how-to/access-teams-context#get-context-by-inserting-url-placeholder-values

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Subba Reddi Tummuru