Search code examples
pythonpython-3.xwindowslocalefrench

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

Solution

  • 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