Providing translations for Android apps

I recently published my first game on the google play store made with corona SDK. I want to translate it to a few other languages. I have friends who would be willing to do it for me, so I would rather do that than pay for google’s translation services. Besides, I can’t really follow google’s translation steps, as those require access to the app’s strings.xml file, which, as far as I know, is hidden by corona. So my questions is: what is the most efficient way to provide translated versions of my game?

Thanks in advance for your help!

Hi,

This was just posted to Corona’s Twitter account. Could be helpful.

http://www.riceburgerlabs.com/2018/03/26/corona-an-approach-to-translations/

-dev

Thanks! Even though I can’t try it out at the moment, this appears to be what I’m looking for, so I’ll go ahead and mark this solved.

For the game I’m trying to work on in my spare time I have a text.lua file that I include everywhere that’s just a big Lua table, something like:

local M = {} M["en"] = {} M["fr"] = {} M["de"] = {} M["es"] = {} M["it"] = {} M["pt"] = {} M["ru"] = {} -- Start a new game M["en"]["newgame"] = "New Game" M["fr"]["newgame"] = "Nouvelle partie" M["de"]["newgame"] = "Neues Spiel" M["es"]["newgame"] = "Juego nuevo" M["it"]["newgame"] = "Nuova partita" M["pt"]["newgame"] = "Novo Jogo" M["ru"]["newgame"] = "Новая игра" -- Resume an existing game M["en"]["resume"] = "Resume" M["fr"]["resume"] = "Reprendre" M["de"]["resume"] = "Fortsetzen" M["es"]["resume"] = "Continuar" M["it"]["resume"] = "Continua" M["pt"]["resume"] = "Continuar" M["ru"]["resume"] = "Продолжить" return M

Then I do something like this to show the text:

 local title = display.newText( sceneGroup, text[myData.language]["selectlevel"], display.contentCenterX, display.contentCenterY - 137, "carbon", 20)

where myData is my “globals/settings” table and “.language” is the saved setting by the user.  The twitter post above uses a CSV file of translations and some code that basically does the same thing. I thought it was a pretty cool way of dealing with translations.  In my case I’m not using strings like “Select Level” as my key, but in retrospect I probably should have. It just keeps the code a little tighter, but I have to remember keys for strings instead of the actual string.

Rob

How does one go about getting the language the system is using? Or do you have to ask for a language during the first launch?

I do something like this in main.lua:

local defaultLanguage = system.getPreference( "locale", "language" ) local supportedLanguages = { en = true, fr = true, de = true, es = true, it = false, ["pt-BR"] = false, ru = false } print("\*\*\*\*\* defaultLanguage", defaultLanguage ) if not supportedLanguages[defaultLanguage] then defaultLanguage = "en" end myData.settings.language = system.getPreference( "app", "language", "string" ) or defaultLanguage print("mydata", myData.settings.language ) myData.language = myData.settings.language

It will look weird that I have a myData.settings.language and a myData.language, but the myData.settings table gets saved/loaded. But I don’t want to type myData.settings.language in every text I use. myData.language is already too long.  Then I have a settings scene where users can change the default language which is why this line comes into play:

myData.settings.language = system.getPreference( "app", "language", "string" ) or defaultLanguage

if I have saved a language preference I use it or fall back to the defaultLanguage.

Rob

I see. Thanks for your help!

Hi,

This was just posted to Corona’s Twitter account. Could be helpful.

http://www.riceburgerlabs.com/2018/03/26/corona-an-approach-to-translations/

-dev

Thanks! Even though I can’t try it out at the moment, this appears to be what I’m looking for, so I’ll go ahead and mark this solved.

For the game I’m trying to work on in my spare time I have a text.lua file that I include everywhere that’s just a big Lua table, something like:

local M = {} M["en"] = {} M["fr"] = {} M["de"] = {} M["es"] = {} M["it"] = {} M["pt"] = {} M["ru"] = {} -- Start a new game M["en"]["newgame"] = "New Game" M["fr"]["newgame"] = "Nouvelle partie" M["de"]["newgame"] = "Neues Spiel" M["es"]["newgame"] = "Juego nuevo" M["it"]["newgame"] = "Nuova partita" M["pt"]["newgame"] = "Novo Jogo" M["ru"]["newgame"] = "Новая игра" -- Resume an existing game M["en"]["resume"] = "Resume" M["fr"]["resume"] = "Reprendre" M["de"]["resume"] = "Fortsetzen" M["es"]["resume"] = "Continuar" M["it"]["resume"] = "Continua" M["pt"]["resume"] = "Continuar" M["ru"]["resume"] = "Продолжить" return M

Then I do something like this to show the text:

 local title = display.newText( sceneGroup, text[myData.language]["selectlevel"], display.contentCenterX, display.contentCenterY - 137, "carbon", 20)

where myData is my “globals/settings” table and “.language” is the saved setting by the user.  The twitter post above uses a CSV file of translations and some code that basically does the same thing. I thought it was a pretty cool way of dealing with translations.  In my case I’m not using strings like “Select Level” as my key, but in retrospect I probably should have. It just keeps the code a little tighter, but I have to remember keys for strings instead of the actual string.

Rob

How does one go about getting the language the system is using? Or do you have to ask for a language during the first launch?

I do something like this in main.lua:

local defaultLanguage = system.getPreference( "locale", "language" ) local supportedLanguages = { en = true, fr = true, de = true, es = true, it = false, ["pt-BR"] = false, ru = false } print("\*\*\*\*\* defaultLanguage", defaultLanguage ) if not supportedLanguages[defaultLanguage] then defaultLanguage = "en" end myData.settings.language = system.getPreference( "app", "language", "string" ) or defaultLanguage print("mydata", myData.settings.language ) myData.language = myData.settings.language

It will look weird that I have a myData.settings.language and a myData.language, but the myData.settings table gets saved/loaded. But I don’t want to type myData.settings.language in every text I use. myData.language is already too long.  Then I have a settings scene where users can change the default language which is why this line comes into play:

myData.settings.language = system.getPreference( "app", "language", "string" ) or defaultLanguage

if I have saved a language preference I use it or fall back to the defaultLanguage.

Rob

I see. Thanks for your help!