Struggling with something that used to be easy

I’ll second the call for more code, as what you’ve provided isn’t enough to make a solid recommendation on. But I’d also check the value of ‘language’ that you’re supplying. For example, if the language is being returned by the call to system.getPreference(), then it could be returning “en-US”, which isn’t accounted for in your translations table, and therefore calling translations["StartButton"][language] would return nil.

I suspect that there’s either a typo at play, or that your language variable isn’t matching one of your pre-defined options. But again, without more code it’s impossible to say for sure.

You could also set up a default language (I’d assume English) by modifying your setting of the language variable thusly:

local language = userDefinedLanguage or system.getPreference("ui", "language") if not translations["Hello"][language] then language = "en" end

Or perhaps more appropriately, define your available languages within your translations module:

translations.languages = {"en", "fr", "de", "es", "it"}

And then poll against that master list to determine if a default should be applied:

local language = userDefinedLanguage or system.getPreference("ui", "language") if not translations.languages[language] then language = "en" end

Good luck - and share more code so we can help you truly get to the bottom of this! :slight_smile:

According to post system.getPreference( “locale”, “country” ) - What exactly does this return?

system.getPreference("locale", "language")

in Lua was designed to return a language code on all platforms, not a localized language name. I believe what you use translations table as keys for example ‘en’ or ‘fr’ (two character country codes).

Note that some language codes have two parts with a separator (ZH-HANT = Traditional Chinese) . On Android this separator is the _, on iOS the separator will be a -.

Locale will be set to a language code that is consistent between platforms. Japanese will be JA for example. For languages with dialects you will get two part language codes like “ZH-HANS” (iOS), android will be “ZH_HANS”. I recommend testing this out in the Android & iOS XCode Simulator to be sure (Make sure to test languages like Chinese).

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

in Lua is supposed to return a localized language name. The idea is it is something you can display in your UI to the end-user.

let’s take it one step at a time, you could have OTHER problems complicating this before you even get to your language table issue…

going back to your original posted code, does even just THIS work with a hardcoded path?

local test = display.newImageRect("assets/Languages/en/startBt.png") print("test = ", test) -- hoping for non-nil

my guess is not, because the width/height parameters are required.  so how about THIS as a second test:

local test = display.newImageRect("assets/Languages/en/startBt.png", 100, 100) print("test = ", test) -- hoping for non-nil

did that work?  if not, then perhaps case-sensitive path or filename is at fault.

at any rate, once you’ve got it working with hardcoded values, THEN you can start applying any/all of the previous good suggestions re “validating” your language lookup and such.