Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get locale in visual studio code

I am currently adding some locales to my extension and command names and configuration descriptions already work.

Now I want to add translations for error messages and popups inside my extension using vscode-nls. However it seems like it doesn't automatically determine the locale of vscode and I can't find any API for this in the documentation. Is there any way for extensions to do this yet or is it only for the built-in commands?

like image 617
WebFreak001 Avatar asked May 27 '26 18:05

WebFreak001


1 Answers

It turns out vscode has an API for this, to get the language you can use vscode.env.language. I guess just base everything around this because there is no actual way to get the locale except maybe on linux by using the locale environment variables. But for language using vscode.env.language should be the best way to get the language in case you override it through the settings file or if you want it to work on all platforms.

like image 106
WebFreak001 Avatar answered May 30 '26 12:05

WebFreak001