Possible problems with locales

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Possible problems with locales

Post 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.
Help us help you: attach a .love.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Possible problems with locales

Post 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.
User avatar
leiradel
Party member
Posts: 184
Joined: Thu Mar 11, 2010 3:40 am
Location: Lisbon, Portugal

Re: Possible problems with locales

Post 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.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Possible problems with locales

Post by bartbes »

Even when I set the appropriate environment variables I can't get lua to use them.
User avatar
leiradel
Party member
Posts: 184
Joined: Thu Mar 11, 2010 3:40 am
Location: Lisbon, Portugal

Re: Possible problems with locales

Post 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
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Possible problems with locales

Post by bartbes »

...
I pass environment variables, I am not calling os.setlocale, purposefully destroying your application is hardly a bug, is it?
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Possible problems with locales

Post by vrld »

bartbes wrote:purposefully destroying your application is hardly a bug, is it?
I think you might be onto something...
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
leiradel
Party member
Posts: 184
Joined: Thu Mar 11, 2010 3:40 am
Location: Lisbon, Portugal

Re: Possible problems with locales

Post 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.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Possible problems with locales

Post 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.
User avatar
leiradel
Party member
Posts: 184
Joined: Thu Mar 11, 2010 3:40 am
Location: Lisbon, Portugal

Re: Possible problems with locales

Post 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:
  1. Code obfuscation (probably solved with Squish.)
  2. 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.
  3. Locale, though I'm not sure if it's a problem or not.
  4. 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 2 guests