It seems you're using Windows. The locale strings are different there. Take a more precise look at the doc:
locale.setlocale(locale.LC_ALL, 'de_DE') # use German locale; name might vary with platform
On Windows, I think it would be something like:
locale.setlocale(locale.LC_ALL, 'deu_deu')
MSDN has a list of language strings and of country/region strings
Answer from Schnouki on Stack OverflowVideos
It seems you're using Windows. The locale strings are different there. Take a more precise look at the doc:
locale.setlocale(locale.LC_ALL, 'de_DE') # use German locale; name might vary with platform
On Windows, I think it would be something like:
locale.setlocale(locale.LC_ALL, 'deu_deu')
MSDN has a list of language strings and of country/region strings
You should not pass an explicit locale to setlocale, it is wrong. Let it find out from the environment. You have to pass it an empty string
import locale
locale.setlocale(locale.LC_ALL, '')
Hi,
That changes things.
You have to customize the startup script and install locales and local-all following these steps: https://azureossd.github.io/2020/01/23/custom-startup-for-nodejs-python/
Source: https://github.com/MicrosoftDocs/azure-docs/issues/51974
Thanks for your support Pierre and Mayank.
Because of the change in the build process on Azure, the deployment no longer happens in a fixed folder.
I used the $APP_PATH variable in the startup script and it seems to be working now.
Thank you for your help.
Unix systems don't really have a “system language”. Unix is a multiuser system and each user is free to pick their preferred language. The closest thing to a system language is the default language that users get if they don't configure their account. The location of that setting varies from distribution to distribution; it's picked up at some point during the login process.
In most cases, what is relevant is not the “system language” anyway, but the language that the user wants the application to use. Language preferences are expressed through locale settings. The setting that determines the language that applications should use in their user interface is LC_MESSAGES. There are also settings for the date, currency, etc. These settings are conveyed through environment variables which are usually set when the user logs in from some system- and user-dependent file.
Finding a locale setting is a bit more complicated than reading the LC_MESSAGES variable as several variables come into play (see What should I set my locale to and what are the implications of doing so?). There's a standard library function for that. In Python, use locale.getlocale. You first need to call setlocale to turn on locale awareness.
import locale
locale.setlocale(locale.LC_ALL, "")
message_language = locale.getlocale(locale.LC_MESSAGES)[0]
Since locale.getdefaultlocale() is deprecated, here is how I do it:
# This is needed, otherwise there is no locale info available
locale.setlocale(locale.LC_ALL, "")
locale_info = locale.getlocale()
# locale_info[0] contains a string similar to Dutch_Belgium
user_lang = locale_info[0].split('_')[0] if locale_info and locale_info[0] else 'English'
lang_code = locale.normalize(user_lang)[:2].lower() if locale.normalize(user_lang) else "en"
The code returns the language in the two-letter iso-639-1 format (for example en, nl, fr).
In this code example, the fallback value is "en" for English.