Local Testing

Using the ACE "Set Lang From String" in Legends of Learning Plugin for Construct 3

In this tutorial, we will explain how to use the ACE Set Lang From String in the Legends of Learning (LoL) Plugin for Construct 3. We will cover what this ACE does, how to use it, and important considerations when implementing it in your game.

What is the Set Lang From String ACE?

The Set Lang From String action is used to manually load a language file for testing purposes while you develop your game locally. It allows you to simulate the text translations for different languages within your game.

Important Note: This action is only for testing and should not be used in the live version of your game. In production, Legends of Learning automatically handles the language files and provides translations for the player based on their language settings.

Step 1: Create a lang.json File for Testing

The Set Lang From String action requires a language file in JSON format that contains translations of the text in your game. This file should be structured like this:

Example of lang.json:

{
  "en": {
    "ui-play": "Play the game",
    "ui-pause": "Pause",
    "level-complete": "Level Complete"
  },
  "es": {
    "ui-play": "Jugar al juego",
    "ui-pause": "Pausa",
    "level-complete": "Nivel Completado"
  }
}
  • "en" is for English text.

  • "es" is for Spanish text.

  • Each key (e.g., "ui-play") represents a string in your game, and the value is the actual translated text.

Step 2: Using the Set Lang From String ACE

The Set Lang From String action allows you to load a language file (in JSON format) into your game during testing. This is crucial when you want to simulate how Legends of Learning will handle language localization in your game.

However, instead of hardcoding the language file in the action, it's better to read the language file dynamically using the AJAX plugin in Construct 3. This allows for a more flexible and scalable approach, especially if you plan to include multiple language files in your project.

Step 3: Create the langTest.json File

Before you can read the language file dynamically, you need to create a langTest.json file in your Construct 3 project. The structure of this file should follow the same format as lang.json required by Legends of Learning.

Example of langTest.json (This file simulates the content for testing):

{
  "en": {
    "ui-play": "Play the game",
    "ui-pause": "Pause",
    "level-complete": "Level Complete"
  },
  "es": {
    "ui-play": "Jugar al juego",
    "ui-pause": "Pausa",
    "level-complete": "Nivel Completado"
  }
}

Save this file as langTest.json in the Files section of Construct 3. This will allow you to load it dynamically during runtime.

Step 4: Set Up the AJAX Plugin and Read the File

  1. Add the AJAX Plugin to your project in Construct 3:

  1. Call Request Project File action to load the language file dynamically:

  1. Parse the AJAX response and inject it into the Legends of Learning plugin using Set Lang From String action.

Please note that the Language parameter of Set Lang From String indicates the plugin to read the entries from the AJAX.LastData that corresponds to the es language. If you want to change the language for testing, modify this parameter and run your project again.

Explanation:

  • AJAX is used to load the langTest.json file asynchronously.

  • Set Lang From String loads the language data into the game from the langTest.json file, allowing your game to render the correct localized text during testing.

Step 5: Considerations for Using "Set Lang From String"

While the "Set Lang From String" action is a helpful tool for testing translations locally, there are a few important considerations to keep in mind:

  1. For Testing Only:

    • Set Lang From String should only be used for testing. In the live version of the game, Legends of Learning will automatically provide the correct translation based on the player's language settings when On Start condition is triggered. You do not need to manually load the language file in production.

  2. Language Files Must Be Complete:

    • Ensure that the lang.json file you are using is complete and contains all the required text keys for your game. If some keys are missing, it might lead to errors or missing translations in the game.

If you provide more than one language in the file, the keys should match in number and key-name, otherwise the platform will reject your language file.

  1. Don't Use In Production:

  • The Set Lang From String action is not necessary in the live game. Legends of Learning automatically sends the appropriate translations, so your game should rely on the platform’s provided language files rather than hard-coding language changes.

  1. Test All Translations:

  • When you upload your lang.json file to Legends of Learning for review, make sure that you have properly tested the Spanish, English, or any other translations in your game. You can use Test

Last updated