It returns “en” for me. What device are you on? Do you have any locales added to your build.settings? Are you building for Android or iOS? What version of Corona SDK are you running?
Hi Rob. Here are the answers:
-
iPhone 4 (6.1 firmware)
-
Windows 7 64bits
-
Corona 2013.1076 (2013.4.3).
-
iOS target.
-
Yes. I have both “en” and “es” added to the build.settings.
The best thing is that the same code works like a charm in my OSX… Weird thing… :wacko:
Thanks in advice.
I have a couple of things… How are you building for iOS on Windows? I think you have to spell out the names in your build.settings. Can you post it?
First of all, apologise for that misunderstanding. I am not building for iOS on Windows. I mean, I started to develop the app on Windows and then I load that code into my Mac for the iOS build. 
Secondly, I have this configured in my build.settings:
CFBundleLocalizations = { "es", "en" },
And this is the configuration for the localized texts (localized.lua):
local localized = { ["Menu"] = { ["es"] = "Menu Principal", ["en"] = "Main Menu" }, } return localized
Lastly, this is the way I load every localized text:
local localized = require("localized") language = system.getPreference( "ui", "language" ) [...] local message = localized["Menu"][language] [...] local t = display.newText(message, img.x + 20, img.y - 14, font, 22)
Thanks,
Cristian.
You have to spell out the names:
CFBundleLocalizations =
{
“English”,
“French”,
“German”,
“Italian”,
“Spanish”,
“Hebrew”,
“Hindi”,
“Chinese”,
“Portugese”
},
Still doesn’t work on Windows… I don’t know what I’m doing wrong. 
Here’s all the code just in case (is not organized and not optimized, etc, etc, just for testing purposes).
Thanks in advice. Anyway is working 100% ok on OSX.
I don’t know how you’re trying to build for device on Windows for iOS. You have to be on a Mac with XCode. This localization is iOS only,
No, no, I am testing in the Simulator on Windows (obvioulsy) and building for iOS on my home’s macBook. Anyway, don’t worry and thanks for the help.
Regards.
Well the build.settings iphone section only applies to apple devices, not the simulator. I guess that those functions should return something, but because windows is windows, that feature might not be available. Let me ask the engineers about this. Maybe it’s something we can add but there are just some operating system differences that may prevent this from working.
Hi,
Great tutorial, I also followed the link and everything works but one thing…
I don’t know if it’s a new change in the API or something but now the line:
language = system.getPreference( "locale", "language" )
returns ‘1033’ (insted of ‘en’).
Any suggestions? Is there any way to get ‘en’ instead of Country codes? :huh:
Thanks,
Cristian.
It returns “en” for me. What device are you on? Do you have any locales added to your build.settings? Are you building for Android or iOS? What version of Corona SDK are you running?
Hi Rob. Here are the answers:
-
iPhone 4 (6.1 firmware)
-
Windows 7 64bits
-
Corona 2013.1076 (2013.4.3).
-
iOS target.
-
Yes. I have both “en” and “es” added to the build.settings.
The best thing is that the same code works like a charm in my OSX… Weird thing… :wacko:
Thanks in advice.
I have a couple of things… How are you building for iOS on Windows? I think you have to spell out the names in your build.settings. Can you post it?
First of all, apologise for that misunderstanding. I am not building for iOS on Windows. I mean, I started to develop the app on Windows and then I load that code into my Mac for the iOS build. 
Secondly, I have this configured in my build.settings:
CFBundleLocalizations = { "es", "en" },
And this is the configuration for the localized texts (localized.lua):
local localized = { ["Menu"] = { ["es"] = "Menu Principal", ["en"] = "Main Menu" }, } return localized
Lastly, this is the way I load every localized text:
local localized = require("localized") language = system.getPreference( "ui", "language" ) [...] local message = localized["Menu"][language] [...] local t = display.newText(message, img.x + 20, img.y - 14, font, 22)
Thanks,
Cristian.
You have to spell out the names:
CFBundleLocalizations =
{
“English”,
“French”,
“German”,
“Italian”,
“Spanish”,
“Hebrew”,
“Hindi”,
“Chinese”,
“Portugese”
},
Still doesn’t work on Windows… I don’t know what I’m doing wrong. 
Here’s all the code just in case (is not organized and not optimized, etc, etc, just for testing purposes).
Thanks in advice. Anyway is working 100% ok on OSX.
I don’t know how you’re trying to build for device on Windows for iOS. You have to be on a Mac with XCode. This localization is iOS only,
No, no, I am testing in the Simulator on Windows (obvioulsy) and building for iOS on my home’s macBook. Anyway, don’t worry and thanks for the help.
Regards.
Well the build.settings iphone section only applies to apple devices, not the simulator. I guess that those functions should return something, but because windows is windows, that feature might not be available. Let me ask the engineers about this. Maybe it’s something we can add but there are just some operating system differences that may prevent this from working.