Hey all,
I’ve been away from my Corona workflows for so long, I’ve pretty much forgotten the most simple stuff. - I’m working with an inbuilt translation table for localising my game, but I’ve been trying to swap text objects for image objects… With no joy.
I made this work years ago, but I’ve completely forgotten how I did it. Just wondered if there’s anyone out there who can put me on track.
Here’s the basic code for the function.
An external file called translations, it looks lime this:
-- translations.lua local translations = { ["Hello"] = { ["en"] = "Hello", ["fr"] = "Salut", ["de"] = "Hallo", ["es"] = "Hola", ["it"] = "Ciao" } } return translations
I then require it into my ‘active’ code:
local translations = require("translations") local language = userDefinedLanguage or system.getPreference("ui", "language")
Then, as a text object, it’s implemented like this:
local myText = display.newText(translations["Hello"][language], 0, 0, native.systemFont, 16)
This is what I’m trying to achieve - - Table:
-- translations.lua local translations = { ["Hello"] = { ["en"] = "assets/Languages/en/startBt.png", ["fr"] = "assets/Languages/fr/startBt.png", ["de"] = "assets/Languages/de/startBt.png", ["es"] = "assets/Languages/es/startBt.png", ["it"] = "assets/Languages/it/startBt.png" } } return translations
The require code is obviously the same, but here’s my attempted implementation:
begin = display.newImageRect(translations["StartButton"][language]) begin .x = 512 begin .y = 300 begin .alpha = 1 begin:addEventListener( "tap", advance )
I’ve introduced the ‘begin’ asset as ‘local’ and included it into a display group… It doesn’t work.
The console error reads: /Users/Home/Desktop/GAME CODE/MyGame/menu.lua:103: display.newImageRect() bad argument #1: filename or image sheet expected, but got nil
Jun 09 11:42:21.856 ERROR: Runtime error
/Users/Home/Desktop/GAME CODE/MyGame/menu.lua:104: attempt to index upvalue ‘begin’ (a nil value)
stack traceback:
If anyone can help, I’d be grateful.
