> For the complete documentation index, see [llms.txt](https://smartui-docs.pixelperfectstudio.mx/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://smartui-docs.pixelperfectstudio.mx/miscellaneous-addons/legends-of-learning-plugin/local-testing.md).

# Local Testing

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 *<mark style="color:blue;">**manually load a language file for testing**</mark>* purposes while you develop your game locally. It allows you to simulate the text translations for different languages within your game.

{% hint style="danger" %} <mark style="color:orange;">**Important Note**</mark><mark style="color:orange;">:</mark> This action is <mark style="color:orange;">**only for testing**</mark> <mark style="color:orange;">**and should**</mark> <mark style="color:orange;">**not be used in the live version**</mark> of your game. In production, Legends of Learning automatically handles the language files and provides translations for the player based on their language settings.
{% endhint %}

### **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`:**

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

<figure><img src="/files/a4dWaJJGymCHsabTEWOR" alt=""><figcaption></figcaption></figure>

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.

<figure><img src="/files/bUhXdGfL3yXoo18mpqKN" alt=""><figcaption></figcaption></figure>

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

```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"
  }
}
```

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

<figure><img src="/files/xkSZ9zGbEJULtOmL6dcQ" alt=""><figcaption><p>Project Bar - Files Section</p></figcaption></figure>

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

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

<figure><img src="/files/GDe6sDviOswqxvIvPZku" alt="" width="300"><figcaption></figcaption></figure>

2. Call **`Request Project File`** action to load the language file dynamically:

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td>Step 1. Request the project file</td><td><a href="/files/FyLLkFVwsINR3Q6DFq8L">/files/FyLLkFVwsINR3Q6DFq8L</a></td></tr><tr><td>Step 2. Set the callback tag and the filename to read</td><td><a href="/files/QcP22oZ0acBSf35IAUA3">/files/QcP22oZ0acBSf35IAUA3</a></td></tr><tr><td>Step 3. Add <strong>On Completed</strong> of the AJAX plugin </td><td><a href="/files/066GvU6B6PqDYd2zdzZe">/files/066GvU6B6PqDYd2zdzZe</a></td></tr><tr><td>Step 4. Assign the callback tag to filter the AJAX response.</td><td><a href="/files/ycGdyKKaHbLCJNBMDidQ">/files/ycGdyKKaHbLCJNBMDidQ</a></td></tr></tbody></table>

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

<figure><img src="/files/gdtW82YZj5xx83goNRXw" alt="" width="410"><figcaption><p>Calling <strong>Set Lang From String</strong></p></figcaption></figure>

<figure><img src="/files/XnTMFLwBUNu0Yl2fRVLQ" alt=""><figcaption><p>Inject the AJAX response and assign a language to operate</p></figcaption></figure>

{% hint style="warning" %}
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. <mark style="color:orange;">**If you want to change the language for testing, modify this parameter and run your project again**</mark><mark style="color:orange;">.</mark>
{% endhint %}

**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.&#x20;

{% hint style="warning" %}
If you provide more than one language in the file, the <mark style="color:orange;">**keys should match in number and key-name, otherwise the platform will reject your language file.**</mark>
{% endhint %}

3. **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.

4. **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**&#x20;
