Unsupported Locale Setting

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
MFGames
Newbie
Posts: 2
Joined: Sun Apr 28, 2024 6:33 pm
Contact:

Unsupported Locale Setting

#1 Post by MFGames »

The issue is that people on seemingly mostly older Windows systems (7 & 8, from what I've seen so far.) get an unsupported locale setting traceback that seems to be in relation to the below code. Some Linux users had this problem, too, but pretty sure I fixed that since it's only been Windows 7/8 since then. I'm currently on Ren'py 8.1.3 (for Steam Deck support).

Code: Select all

init python:
    import locale
    if renpy.linux:
        locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
    else:
        locale.setlocale(locale.LC_ALL, 'en_US')
And it's shown in the game menu like this:

Code: Select all

hbox:
        xpos 25
        ypos 25
        imagebutton:
            at zoom2
            idle "gui/missfortune/buttons/animbuttons/money/money001.png"
            hover "moneyvid"
            hovered Play("sound", "music/hover.wav")
            action NullAction()
            
        text "{}".format(locale.currency(mc_money, grouping=True)) font 'gui/missfortune/fonts/Montserrat-Light.ttf' size 35 xpos 7 ypos 20 color '#969798'

Then there's the obvious $ mc_money += 1000 in the script, the usual way of adding/subtracting numbers. Both of my PCs are Windows 11 and the VN works fine, nor do I have a Linux machine (or knowhow) to test on. So, it's nigh impossible for me to test what's going on efficiently. Is it Ren'py 8 having conflicts with older systems? Or is it something with the code? Google seems to bring up quite literally nothing. Traceback image is attached, as well. Any help is appreciated.

This is driving me bonkers.

Image

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2420
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Unsupported Locale Setting

#2 Post by Ocelot »

In short: locales on windows are broken. Older versions were using non BCP47 language names, some only allows for hyphens instead of underscores in locale names, some combinations of settings set some globabl flags that setlocale cannot change, but are incompatible with some other locales.

Windows 10 somewhat improved in this regard, but there was a longstanding bug in locales that was only fixed in Python 3.8 and later.

Also Windows 7 is no longer supported by RenPy.
< < insert Rick Cook quote here > >

MFGames
Newbie
Posts: 2
Joined: Sun Apr 28, 2024 6:33 pm
Contact:

Re: Unsupported Locale Setting

#3 Post by MFGames »

Ocelot wrote: Mon Apr 29, 2024 2:43 am Windows 10 somewhat improved in this regard, but there was a longstanding bug in locales that was only fixed in Python 3.8 and later.

Also Windows 7 is no longer supported by RenPy.
As far as I'm aware, 8.1.3 works with Windows 7. I believe I read that it was 32-bit that was unsupported.

Anyways, for anyone who's running into a similar issue in the future, I wanted to add a simple money system that added proper decimal/comma placement. The original code I got was the above locale code, which ended up causing a decent amount of problems.

I did manage to fix it by getting rid of the locale part all together. It's like Ocelot described, it word fine on more modern systems (W10/W11), but threw the above error with older ones. I got some help on another forum. As mentioned, ditch the locale stuff. In my code above, I had this:

Code: Select all

hbox:
        xpos 25
        ypos 25
        imagebutton:
            at zoom2
            idle "gui/missfortune/buttons/animbuttons/money/money001.png"
            hover "moneyvid"
            hovered Play("sound", "music/hover.wav")
            action NullAction()
            
        text "{}".format(locale.currency(mc_money, grouping=True)) font 'gui/missfortune/fonts/Montserrat-Light.ttf' size 35 xpos 7 ypos 20 color '#969798'
What you want to do change is change the text line, like so:

Code: Select all

text '${:.2f}'.format(mc_money) font 'gui/missfortune/fonts/Montserrat-Light.ttf' size 35 xpos 7 ypos 20 color '#969798'
Change mc_money to whatever your money variable is (and obviously change the to your proper directory). And in my case, it ends up looking like this:

Image

Post Reply

Who is online

Users browsing this forum: giorgi1111