简体   繁体   中英

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

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

add this in RobotFramework (at the beginning):

${osName}=    Evaluate    platform.system()    platform
Run keyword if    "${osName}"=='Windows'    Evaluate    locale.setlocale(locale.LC_ALL, 'french')    locale
    ...         ELSE    Evaluate    locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')    locale

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM