Change texts according to the language of game

0 favourites
  • 10 posts
From the Asset Store
Implement multi-language translation inside your game effortlessly with the language.translate plugin!
  • 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.

  • 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.

  • 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.

  • You need this:

    there are example files as well. Use Ajax.lastdata in the field where you put the string.

  • Hi. Thanx again. one more thing I want to ask. The AJAX.LastData is sometimes null. Is there any possible reason for that ?

  • I don't know. Do you wait for the Ajax request to be completed before you enter the data into the CSV-plugin?

  • 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.

  • 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).

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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:


    <img src="" border="0" />

  • 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).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 me

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)