Page 2 of 2
Re: Possible problems with locales
Posted: Sun Oct 10, 2010 8:07 am
by Robin
Thing is, when I was using Dutch locale Windows and Linux, I never had any problems.
Now I can get the error by using 'fy_NL', which is installed on my system, but my guess is that the default locale in Lua is always 'C' anyway.
Re: Possible problems with locales
Posted: Sun Oct 10, 2010 9:41 am
by bartbes
It is not clearly defined it seems (it's an implementation detail), but since locales have the possibility of breaking the entire language, I would assume it is a 'normal' locale by default.
Re: Possible problems with locales
Posted: Mon Oct 11, 2010 3:08 pm
by leiradel
Robin wrote:<snip>, but my guess is that the default locale in Lua is always 'C' anyway.
I think the locale of running processes is the default locale of the OS. Lua 5.1.4 doesn't change the locale so if processes do inherit the locale from the OS it's just a matter of finding someone with a weird locale to make the test script break.
For now I'll just add os.setlocale('C') to love.load but I think the best thing to do would be to have LÖVE both set the locale to C and remove setlocale from the os library.
Re: Possible problems with locales
Posted: Mon Oct 11, 2010 3:25 pm
by bartbes
Even when I set the appropriate environment variables I can't get lua to use them.
Re: Possible problems with locales
Posted: Mon Oct 11, 2010 3:44 pm
by leiradel
bartbes wrote:Even when I set the appropriate environment variables I can't get lua to use them.
Are you calling os.setlocale without arguments to see what the locale is when the script starts? And is the locale you're using a "weird" one?
This script
Code: Select all
print(os.setlocale())
print('---')
os.setlocale('fra_fra')
print(os.setlocale())
print(1.5)
print(tonumber('1.5'))
pcall(function () print('1.5' + 0) end)
print('---')
os.setlocale('C')
print(os.setlocale())
print(1.5)
print(tonumber('1.5'))
pcall(function () print('1.5' + 0) end)
gives me the following output:
Code: Select all
C
---
French_France.1252
1,5
nil
---
C
1.5
1.5
1.5
Re: Possible problems with locales
Posted: Mon Oct 11, 2010 3:57 pm
by bartbes
...
I pass environment variables, I am not calling os.setlocale, purposefully destroying your application is hardly a bug, is it?
Re: Possible problems with locales
Posted: Mon Oct 11, 2010 4:02 pm
by vrld
bartbes wrote:purposefully destroying your application is hardly a bug, is it?
I think you might be onto something...
Re: Possible problems with locales
Posted: Mon Oct 11, 2010 5:13 pm
by leiradel
bartbes wrote:...
I pass environment variables, I am not calling os.setlocale, purposefully destroying your application is hardly a bug, is it?
Sure it's not, I'm worried if the OS locale does cause problems when one forgets to explicitly set the locale to C which is still an open question to me.
Re: Possible problems with locales
Posted: Mon Oct 11, 2010 5:15 pm
by bartbes
As I said, I set the environment variables (as close as setting the OS locale as we're going to get), never set it in lua, and it uses c locale.
Re: Possible problems with locales
Posted: Mon Oct 11, 2010 5:25 pm
by leiradel
vrld wrote:bartbes wrote:purposefully destroying your application is hardly a bug, is it?
I think you might be onto something...
I'm just trying to make LÖVE more robust and make it a viable option for commercial games and for that I'd like to have these:
- Code obfuscation (probably solved with Squish.)
- Power of 2. I'd upload all textures with adjusted sizes to make them PO2 and create an option to disable this behavior in love.conf.
- Locale, though I'm not sure if it's a problem or not.
- I18n, though bartbes is taking care of it.
As for me, I'm solving these issues with Squish, having all my images PO2, calling os.setlocale('C') on love.load and waiting for the i18n library, and hope that no one forgets to take measures against these issues specially if shipping a game worldwide.