I'm trying to change the default language on the Azure machine hosting my app. Currently, the default language is set to en_US.UTF-8 and is the only one in locale.gen, but I need to configure it to it_IT.UTF-8 to support my Django project. When I start my app and the Django app execute the "import locale" command followed by "locale.setlocale(locale.LC_TIME, 'it_IT.utf8')", I get the "unsupported locale setting" error. I suspect that the Italian language is not properly configured in the system. What are the necessary steps to change the default language and add the it_IT.UTF-8 locale to locale.gen on Azure? Or any others solution? Thank you in advance for your assistance!
I created a startup.sh file in the home directory (the only persistent location) with the following commands: echo "it_IT.UTF-8" >> locale.gen locale-gen
Then, in the Azure App configuration under General settings, I specified the path /home/startup.sh in Stack Settings > Startup Command. However, when I attempted to start the machine with this configuration, the startup failed for unknown reasons.
I expected the startup.sh script to modify the locale.gen file and generate the it_IT.UTF-8 locale successfully.
You can make use of the sample github repository here by very academy.
In your settings.py add this code to set the default language and import new languages like below:-
settings.py
Here default language is set to English - en and rest all the languages are imported.
Now, Create 3 folders for different languages English, French and Italy in locale folder. And run the command below to populate the language translation setting in the same like below:-
Open your virtual environment with the commands below:-
And run the command below to populate the settings:-
Now, Visit locale> it > django.po file and write the text you need to translate instead of hello, I have written ciao like below:-
Now, Run the app from virtual environment locally using the command below:-
The Web app will load like below, Change the language to French and Italian and get your desired language translated within the web app.
No, I deployed this application to Azure Web app with Python runtime and it git deployed successfully like below:-
Before deployment in **settings.py ** add allowed host to your azure web app host name like below:-
In your scenario you can change the default language by adding
it_IT.UTF-8in your local.gen.If local.gen does not exist create it.
Now, In your settings.py file add the following code:-