Change texts according to the language of game

Get help using Construct 2

Post » Sat Nov 23, 2013 8:42 am

Hello Everyone,

I am building a simple quiz game. I want that the texts in my game (such as instructions, questions, options etc.) change as per the language user choose. I have 10 languages and all translations are ready. I am new to this engine and am glad to say that I am very fascinated from the initial experience. I can feel this can do a lot more than currently I can imagine.

Thank You.Raganork2013-11-23 08:51:12
B
6
S
2
G
1
Posts: 77
Reputation: 708

Post » Sat Nov 23, 2013 12:31 pm

Use an array where you store all you text. All texts (that are translatable) should be loaded from this array.

In an options menu where you can set the language you can dynamically load the array of the fitting language from your project files. To do that you can:

Either use the CSVtoArray-Plugin (you need to download it from this forum), export your spreadsheet with the texts for one language to .csv, copy the string and input it into the game (need to exchange " to "" beforehand).
Another option is to load a JSON string into the array. To get that JSON file you can use array -> download as json beforehand. Later on include the .json in your project files, add the Ajax-object, request a project file and upon request complete use array -> load from json ajax.lastdata
But for the second method you obviously need to have the data ingame already. Sure you can also export a blank array with the size you need and then just edit the .json in a text editor and fill it with the texts.
mindfaQ2013-11-23 12:33:03
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Mon Nov 25, 2013 1:17 pm

Hi, Thanx for the reply. I tried your solution, but not getting the expected output. I converted my xls file to csv and tried to load it by AJAX. It is showing me that data is there (in AJAX.LastData) But from here on, I am getting confused.

Can you provide me a demo project on how to do it please. I will be very thankful if you did.
B
6
S
2
G
1
Posts: 77
Reputation: 708

Post » Mon Nov 25, 2013 1:32 pm

You need this: http://www.scirra.com/forum/plugin-csv-csv2array_topic46096.html
there are example files as well. Use Ajax.lastdata in the field where you put the string.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Mon Nov 25, 2013 1:51 pm

Hi. Thanx again. one more thing I want to ask. The AJAX.LastData is sometimes null. Is there any possible reason for that ?
B
6
S
2
G
1
Posts: 77
Reputation: 708

Post » Mon Nov 25, 2013 2:21 pm

I don't know. Do you wait for the Ajax request to be completed before you enter the data into the CSV-plugin?
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Mon Nov 25, 2013 2:59 pm

for my project I went a much easier way. I have several XML files, one for each language, with a unique suffix for each language: menus_en.xml, menus_fr.xml, dialogues_en.xml, dialogues_fr.xml...

Then in the game, I just have a global variable "language", which I set to "en" for english or "fr" for french. Then I just load the xml files with ajax by providing the parameter "menus_2&language. By keeping the text outside of construct, it is easier to edit, maintain or to add new languages.

In fact I also detect the browser's language with the Browser plugin. If it matches one of the supported languages, it will set to that language by default, else it loads english. But you must still give the user the option to change it manually.
B
12
S
5
G
2
Posts: 132
Reputation: 2,627

Post » Tue Nov 26, 2013 2:38 pm

@mindfaQ: I think I requested it late in my project. Now I am requesting it in loader layout, so now i am getting data every time. Thanx for pointing that out.
In example, it is taking data directly, not from AJAX. Although not confused this time, but I am still stuck at same place (data from AJAX.LastData is not coming into CSV.TableToString). Can you please help again ?


@OlivierC: That might be a option, but dont you think its making crowd of xml files, I mean I have at least 65+ translations to do in 10 languages. So wont it take much space and slow the performance ? (just asking).
B
6
S
2
G
1
Posts: 77
Reputation: 708

Post » Tue Nov 26, 2013 3:39 pm

@OlivierC: that's what I was suggesting, just using .csv instead of .xml because they are easier to export from spreadsheets if I am not mistaken

@Ragnarok: example: http://s000.tinyupload.com/index.php?file_id=97539836385339633987
image:
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Tue Nov 26, 2013 4:07 pm

[QUOTE=Raganork]@OlivierC: That might be a option, but dont you think its making crowd of xml files, I mean I have at least 65+ translations to do in 10 languages. So wont it take much space and slow the performance ? (just asking).[/QUOTE] Actually, regarding performances, I think it's more wasteful to have everything stored inside the construct project itself, people will have to load everything, including all the text for the languages they are not going to need, while by storing the text in separate XML file, they only load the on they need. Plus, you need to correct a typo or modify something? no problem with XML, edit the file, re-upload, done. You can even edit it directly online. Within the construct project, open the project, edit your big-ass array, re-export everything, re-upload the whole game...

@mindfaQ: Yeah it's true, but I try to avoid plugins when possible, and in that case, XML works just fine for meOlivierC2013-11-26 16:17:19
B
12
S
5
G
2
Posts: 132
Reputation: 2,627

Next

Return to How do I....?

Who is online

Users browsing this forum: Lordshiva1948, plinkie, sublimate and 12 guests