Language change based on system set

Hello everybody

How to perform this:
If the system language is English - the app interface in English;
elseif the system language is French - the app interface in French.

Should I add some lines of code into build.settings.
What is the best way to store supported languages for an app and how to include it in a build - a separate lua file, xml, json, or main.lua.

Appreciate your answers.

Weirdy, novice

Hello and welcome to the community!

You’ll probably want to use https://docs.coronalabs.com/api/library/system/getPreference.html to get information concerning the language (see the example).

Then you can use that information to choose which translations to load.

Personally, the way how I handle translations is that I place them all inside one .lua file and simply load a corresponding language table from the file after I’ve determined the language in main.lua.

GBC Language Cabinet will help with this.

@XeduR, I’m sorry, I can not undestand this cases in getPreference function:
On Android, system.getPreference( “ui”, “language” ) MAY return English instead of en.
In the Corona Simulator for Windows, the value returned by system.getPreference( “ui”, “language” ) MAY not match the expected value.
How could I receive only expected returned values…

My app works like an interactive dashboard, for example:

ENGLISH
App: How old are you?
User: 19.
App: Wow, it’s approximately 7000 days!

SPANISH
App: ¿Que edad tiene?
User: 19.
App: Guau, casi 7000 años!

UKRAINIAN
App: Скільки тобі років?
User: 19.
App: Нівроку, це ж майже 7000 днів!

@schizoid2k, it’s looks like what I was looking for. I will try to train it to have a deal with user inputs.