no matter on the system settings, whether it’s on simulator [on mac] or on a device [android] the date is always formatted using english locale [so I get Nov instead of Lis for example].
Is there any way to fix this, or do I have to do it on my own?
If I have to do it on my own, do you know any reasonable way to get the date formatted as per locale?
I don’t want users to have weird date formatting, for example US date format [month before day] makes no sense to me.
I get the day/month VS month/day confusion - I have to use the US format but find day/month makes a lot more sense [import]uid: 52491 topic_id: 32800 reply_id: 130497[/import]
I get the day/month VS month/day confusion - I have to use the US format but find day/month makes a lot more sense [import]uid: 52491 topic_id: 32800 reply_id: 130497[/import]
We are using something similar for i18n, however I was wondering about the dates.
I guess I’ll just create a separate date formatting string for every language I want to support and put it as another locale entry.
Thanks again,
good that we have you here.
We are using something similar for i18n, however I was wondering about the dates.
I guess I’ll just create a separate date formatting string for every language I want to support and put it as another locale entry.
Thanks again,
good that we have you here.
Well, if the problem is only about date vs month or month vs date (what should come first), well, I’ll suggest to take a closer look to this.
And, as for localization, the technique described in Monkeybin post is simple, yet you might want to try a dedicated library, named i18n, which handles localization tremendously well. Plus, it features pluralization.
Well, if the problem is only about date vs month or month vs date (what should come first), well, I’ll suggest to take a closer look to this.
And, as for localization, the technique described in Monkeybin post is simple, yet you might want to try a dedicated library, named i18n, which handles localization tremendously well. Plus, it features pluralization.
Have you read through the comprehensive tutorial on working with times and dates? I think you can get this value output as UTC time, then parse it as you see fit. Please read the entire section “Working With Dates” here:
The os.date() function returns whatever the native device’s operating system returns for the C library function strftime(). You can google that to learn more about it. Corona and Lua are just passing this value through to and from strftime(). The work around if you can’t learn how to localize strftime() would be to create your own look up tables:
local dayOfWeek = { “lunes”, “martes”, “miércoles”,“jueves”,“viernes”,“sábado”,“domingo”}
print( dayOfWeek[os.date("%w")+1] )
(The +1 is the fact that %w returns 0-6, afterall C is a 0 based language and you have to add one to adjust to Lua being a 1 based language with arrays).
I use look up tables for the localization of the app-menu.
But for outputting the name of weekday/month i was hoping for a more universal and automatic solution to support all possible languages (not just the ones in my LUT).
I thought i could just use “os.setlocale(‘xx_XX’)” (where the identifier ist read from system.getPreference(locale/ui))
This works fine in the corona- and the xcode simulator.
But if the information in the book “Learn Lua for iOS Game Development by Jayant Varm” is right, os.setlocale isn’t supported on the actual device.
Have you read through the comprehensive tutorial on working with times and dates? I think you can get this value output as UTC time, then parse it as you see fit. Please read the entire section “Working With Dates” here:
The os.date() function returns whatever the native device’s operating system returns for the C library function strftime(). You can google that to learn more about it. Corona and Lua are just passing this value through to and from strftime(). The work around if you can’t learn how to localize strftime() would be to create your own look up tables:
local dayOfWeek = { “lunes”, “martes”, “miércoles”,“jueves”,“viernes”,“sábado”,“domingo”}
print( dayOfWeek[os.date("%w")+1] )
(The +1 is the fact that %w returns 0-6, afterall C is a 0 based language and you have to add one to adjust to Lua being a 1 based language with arrays).
I use look up tables for the localization of the app-menu.
But for outputting the name of weekday/month i was hoping for a more universal and automatic solution to support all possible languages (not just the ones in my LUT).
I thought i could just use “os.setlocale(‘xx_XX’)” (where the identifier ist read from system.getPreference(locale/ui))
This works fine in the corona- and the xcode simulator.
But if the information in the book “Learn Lua for iOS Game Development by Jayant Varm” is right, os.setlocale isn’t supported on the actual device.