Translate your game with the Translate Plugin

Favourite 12 favourites
Tutorial written by armaldioOriginally published on 21st, May 2016 - 1 revision

Translating a game or an app can be boring and very dificult sometimes.
Now, with the Transalte plugin, it's a bit easy !

Setup

First, download the project from github, then extract it to a folder in your C2/plugin folder.
Restart construct 2.

File format

The file is JSON. If you don't know JSON, you can read about it here
The format is simple :

    default_language

It's the language by default, if you didn't choose anyone.

    availables

It's the list of supported languages. Don't put a language here if you didn't translate the all the fields (NOTE : If a field is not available in the selected langauge, default_language will be used)

    play_button next_button greeting_text

You'll have to enter these name to retrieve the according translation. Make sure you choose simple names otherwise you'll have to keep an eye every time on your transaltion file.

Inside these names, you will have to enter the translation according to a key:value system.
Where key is your language and value is the translation.

I think it's all for this part :)

Event sheet

Now, let's go to the construct part !
The first you have to do, is to load the translation file you've just made.
For this, there are two ways.

Retrieving the file - Local

Put the file inside your project files and make an AJAX request (it's a native plugin) to retrieve it's data

Then load the retrieved value with the Load action of the transalte plugin.
Just put AJAX.LastData inside the field.


Retrieving the file - Distant

Imagine you don't want to translate the file yourself.
Put the file on a communautary website like github and instead of making an ajax request to a project file, make it to the raw url to the transaltion file.
You now just have to let people do the work on you public repository, validate the changes and the project is translated. No need to update the project.
CAUTION : If your project can also run offline make sure to have a copy of the file inside the project, otherwise, there probably be a problem when your user have no connection, haha ...

Managing translations


Make an update function that you can call directly on the begining of the layout and also when the user change the language.

Set the text of each of your object to

    Translate.GetValue("play_button", "")

Note that this function take two parameters.
The first parameter is the string you defined in your JSON file.
The second parameters is to pass parameter to the string.
In my JSON file, I have defined that a field will take parameters :


The parameter are between "$"
To replace these parameters, fill the second parameter of the plugion action like this :

"wordbetween$:variable;secondwordbetween$:variable;"
Example :


I think now you are ready ! If you have any questions fell free to ask onthe forum or on the c2 discord server

Enjoy ;)

Based on a TheRealDannyyy idea.

Unlock your full gamedev potential

Upgrade to the Personal Edition of Construct 2, it has way more features and won't holding back from making money and using your full creativity like the free edition does. It's a one off payment and all Construct 2 editor updates are free for life!

View deals

Plus, it's got a lot of additional features that will help you save time and make more impressive games!

Congratulations on finishing this tutorial!

Did you learn a lot from it? Share it now with your friends!

Share and Copy this Tutorial

You are free to copy, distribute, transmit and adapt this work with correct attribution. Click for more info.

Comments

1
el3um4s 8,813 rep

Nice!
Thank's
:)

Saturday, May 21, 2016 at 7:16:16 PM
0
Tedg 9,889 rep

Thanks for share this !)

Thursday, May 26, 2016 at 7:16:07 AM
0
AndreasR 29.2k rep

That's just awesome! I was waiting too long for such a plugin :)
Does it also work on CocoonIO/Intel XDK (Cordova based games)?

Thank you!

Friday, May 27, 2016 at 12:47:33 PM
0
armaldio 5,758 rep
That's just awesome! I was waiting too long for such a plugin :)
Does it also work on CocoonIO/Intel XDK (Cordova based games)?

Thank you!
quoted from AndreasR

Yes, it should ;)

Sunday, June 05, 2016 at 7:02:12 PM
0
Saad Swad 11.5k rep

Awesome plugin! thanks!
It works on PC but not on mobile. I think the Ajax request failed : [Hyperlink removed - users with less than 500 rep cannot post links]

Have you an issue ?

Thanks

Sunday, June 26, 2016 at 11:44:13 AM
0
webstan 709 rep

Thanks for this plugin!

On Intel XDK don't use minify script option otherwise it won't work!

Saturday, July 23, 2016 at 4:46:11 PM
0
jagoman 564 rep

Is there a way to be able to use this for Construct 3?

Saturday, July 15, 2017 at 4:15:43 PM
0
kentoy 498 rep

I love the plugin, it works good on C2. But after I export to html5 and upload to server, it can not work. Have you tried on server?

Monday, October 16, 2017 at 6:19:49 PM

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.