Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - How to set French locale?

locale.setlocale(locale.LC_ALL, 'french') work on my local machine (windows 7 + Python 3)

locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8') work on my other machine (Unix) but if I use this on my local machine, I have this error:

locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')' failed: unsupported locale setting
like image 431
Stéphane GRILLON Avatar asked Apr 05 '19 09:04

Stéphane GRILLON


People also ask

How do I change the locale in Python?

Probing the Current Locale The most common way to let the user change the locale settings for an application is through an environment variable ( LC_ALL , LC_CTYPE , LANG , or LANGUAGE , depending on the platform). The application then calls setlocale() without a hard-coded value, and the environment value is used.

What is locale library in Python?

Python's locale module is part of the standard library for internationalization (i18n) and localization (l10n) in Python. The locale module allows developers to deal with certain cultural issues in their applications.


1 Answers

Locale settings are OS dependent and, at least on *nix systems, might even depend on whether they are installed or not.

This SO post might be a good pointer to what locales to use on Windows systems: https://stackoverflow.com/a/956084/2186184

like image 74
Jonathan Avatar answered Oct 20 '22 21:10

Jonathan