How to make translate a game from an Array or Dictionary

0 favourites
  • 8 posts
From the Asset Store
language.translate
$11.25 USD
25% off
Implement multi-language translation inside your game effortlessly with the language.translate plugin!
  • I know how to take values from an array(Lang.At), but I don't understand how to pass a string to the "Text" module. From the dictionary, too, it is not clear how to take strings.

    My game detects the language automatically depending on the language of the device, and am only need to do this check in the place, and substitute the necessary lines from the json file.

  • Check out this template:

    editor.construct.net

    I've also seen a few tutorials, you can try googling.

    I think the easiest way would be using a dictionary. Prepare a separate dictionary file for each language in the project, for example "Strings-EN.json", "Strings-FR.json"

    On startup when you detect device language, request the required file with AJAX and load it into the Lang dictionary. In this dictionary you can use codes as keys and translations as values. For example, the key can be "GameOverText" and the value in the French file can be "Jeu terminé!"

    And then you set text for your text object to Lang.Get("GameOverText")

  • Check out this template:

    https://editor.construct.net/#open=languages-from-json

    I've also seen a few tutorials, you can try googling.

    I think the easiest way would be using a dictionary. Prepare a separate dictionary file for each language in the project, for example "Strings-EN.json", "Strings-FR.json"

    On startup when you detect device language, request the required file with AJAX and load it into the Lang dictionary. In this dictionary you can use codes as keys and translations as values. For example, the key can be "GameOverText" and the value in the French file can be "Jeu terminé!"

    And then you set text for your text object to Lang.Get("GameOverText")

    Thank you, it worked with the dictionary, but only with one. I connect the second one, just like the first one, but it doesn't work.

  • No, I meant you only need to load one file. If device language is English, load English file, if Russian - load Russian. Use the same AJAX tag. So as a result, the dictionary will contain strings only for one language.

  • No, I meant you only need to load one file. If device language is English, load English file, if Russian - load Russian. Use the same AJAX tag. So as a result, the dictionary will contain strings only for one language.

    Thank you, I didn't immediately understand what you meant)

    But now everything works as it should)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Another small question, maybe I couldn't find it, but how do I do line wrapping in a dictionary?

    The HTML <br> tag doesn't work, and as I understand it, C3 doesn't have its own tag for transferring?

  • I usually use some character, for example ^. And then replace this character with newline expression.

    For example, you may have this text in the dictionary:

    Hello there,^general Kenobi!

    When you're showing it on the screen, you can do this:

    Text set text to replace(Dictionary.Get("greeting"), "^", newline)

    .

    And of course you can optimize the code by creating a function, which will return formatted text from the dictionary for any key.

  • I usually use some character, for example ^. And then replace this character with newline expression.

    For example, you may have this text in the dictionary:

    Hello there,^general Kenobi!

    When you're showing it on the screen, you can do this:

    Text set text to replace(Dictionary.Get("greeting"), "^", newline)

    .

    And of course you can optimize the code by creating a function, which will return formatted text from the dictionary for any key.

    Thanks)

    But it is strange of course that the developers did not make a tag)

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