problem with (system.getPreference( "ui", "language" ))

Hi,

I’m trying to customize a button by the device language so I wrote these lines :

[lua]if (system.getPreference( “ui”, “Arabic” )) then
local ar = display.newImage(“AR.png”)
ar.x = 160; ar.y = 240;
else
local en = display.newImage(“EN.png”)
en.x = 160; en.y = 240;
end[/lua]

I’m testing on an arabic device but I don’t get the arabic button !?

I think you may have misread the documentation.  You should do something like:

if system.getPreference( “ui”, “language” ) == “Arabic” then

You can’t call system.getPreference( “ui”, “Arabic” ), it has to be the string “language”.

You also need to print out the value and see what it returns.  It could return “Arabic” or “ar” or some other string.  You need to find out the value by printing it out before you start writing tests around it.

Rob

thank you rob, now it worked :slight_smile:

I think you may have misread the documentation.  You should do something like:

if system.getPreference( “ui”, “language” ) == “Arabic” then

You can’t call system.getPreference( “ui”, “Arabic” ), it has to be the string “language”.

You also need to print out the value and see what it returns.  It could return “Arabic” or “ar” or some other string.  You need to find out the value by printing it out before you start writing tests around it.

Rob

thank you rob, now it worked :slight_smile: