Forum Discussion
Question about MS Teams SDK for app.initialize/ app.getContext
Dear Sir
I have an issue about Microsoft Teams Addin - SDK to get Teams locale for language setting.
Here are my code and result.
app.initialize().then( () => {
app.getContext().then((context: Context) => {
getLang = context.app.locale;
/* .... */
Thing is it takes much time to get Context . The result is
- Web Teams in Chrome browser : around 380ms
- Desktop Teams : around 130ms
During this elapse time, my other language setting is executed with initial value( 'null' in example).
Is it normal time? Is there any way to get faster?
Many thanks
BH
byungheesohn, the times you mentioned: around 380ms for Web Teams in Chrome and 130ms for Desktop Teams, are within a reasonable range, but there are ways to optimize and potentially reduce this delay. Using URL placeholders can be a more efficient way to access context information without the delay associated with
app.getContext
.By using URL placeholders, you can directly embed the locale information in your URLs, which can help reduce the delay.
const url = `https://your-app-url.com?locale={app.locale}`;
Get Contextual Information for Tabs - Teams | Microsoft Learn
Thanks,
Prasad Das
------------------------------------------------------------------------------------------
If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.
- Prasad_Das-MSFTMicrosoft
byungheesohn, the times you mentioned: around 380ms for Web Teams in Chrome and 130ms for Desktop Teams, are within a reasonable range, but there are ways to optimize and potentially reduce this delay. Using URL placeholders can be a more efficient way to access context information without the delay associated with
app.getContext
.By using URL placeholders, you can directly embed the locale information in your URLs, which can help reduce the delay.
const url = `https://your-app-url.com?locale={app.locale}`;
Get Contextual Information for Tabs - Teams | Microsoft Learn
Thanks,
Prasad Das
------------------------------------------------------------------------------------------
If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.
- user2160Copper Contributor
Dear Sir
Thank you so much for your help.
I can get the Teams locale without any delay.
Actually I didn't have any understanding about URL placehoder.
After googling about URL placehoder, I updated my manifest.json about contentUrl below. "contentUrl": "https://my_url.com/index.html?locale={app.locale}",
And in my source code, I added the followings.
const urlParams = new URLSearchParams(window.location.search);const myLang = urlParams.get('locale');It works very well.
Many thanksBH- Prasad_Das-MSFTMicrosoft
user2160, glad to hear that it worked.
If the response was helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link.