Help with developing for more than one language

Hello, 

I am developing my first book for kids and I would like it to support different languages (portugeuese, english and spanish).

My question is: Should I create onde app with each language, or there is one possible way to make the three options in the same code, and if so, how would I do that?

Thank you a lot for your attention, 

greetings from Brazil

Hi @carlos.rafael,

Well, you could make different apps, but I would suggest you make just one. Then, for each language, it depends on where you need to show different text in each language. I assume that you would create some menu for the user to select a language. From there, you would have a database or other file containing the text for each language and, depending on the user’s choice, you would display the proper text in all places.

Hope this helps,

Brent

Hello @Brent, thank you a lot for your answer.

I also was thinking in developing just one app with all the languages inside.

Yes, I would create one menu where the user could choose the right language for him.

I am using composer template to develop it and Iam trying to code the best way as possible(talking about memory, code and optimization). 

So to make it clear, do you think handle like this is a good idea?

1- Create for example three files(portuguese.lua, english.lua and spanish.lua), with different strings.

2- Create the menu with the three choices of language and also one global variable wich will save the choice(portuguese, english or spanish)

3- Depending on the choice of the user, on the top of each screen(composer), I would load the file according to the global variable wich has the choice of the user.

I don’t know if this is the optmal way to handle it, and as I am developing for three languages, I am afraid the size of the app will be very big.

Hi @carlos.rafael,

Yes, separate files would be OK if you only need to replace the language in one (or a few) scenes. However, if you need to replace the language in many, many places throughout the app, I suggest that you create your language setup using JSON, and put each language into separate JSON “tables”. Then, you can read the exact language from the JSON file, and from a specific place within the file.

Here is the documentation on JSON for reference:

http://docs.coronalabs.com/api/library/json/index.html

Best regards,

Brent

Hi @carlos.rafael,

Well, you could make different apps, but I would suggest you make just one. Then, for each language, it depends on where you need to show different text in each language. I assume that you would create some menu for the user to select a language. From there, you would have a database or other file containing the text for each language and, depending on the user’s choice, you would display the proper text in all places.

Hope this helps,

Brent

Hello @Brent, thank you a lot for your answer.

I also was thinking in developing just one app with all the languages inside.

Yes, I would create one menu where the user could choose the right language for him.

I am using composer template to develop it and Iam trying to code the best way as possible(talking about memory, code and optimization). 

So to make it clear, do you think handle like this is a good idea?

1- Create for example three files(portuguese.lua, english.lua and spanish.lua), with different strings.

2- Create the menu with the three choices of language and also one global variable wich will save the choice(portuguese, english or spanish)

3- Depending on the choice of the user, on the top of each screen(composer), I would load the file according to the global variable wich has the choice of the user.

I don’t know if this is the optmal way to handle it, and as I am developing for three languages, I am afraid the size of the app will be very big.

Hi @carlos.rafael,

Yes, separate files would be OK if you only need to replace the language in one (or a few) scenes. However, if you need to replace the language in many, many places throughout the app, I suggest that you create your language setup using JSON, and put each language into separate JSON “tables”. Then, you can read the exact language from the JSON file, and from a specific place within the file.

Here is the documentation on JSON for reference:

http://docs.coronalabs.com/api/library/json/index.html

Best regards,

Brent