> For the complete documentation index, see [llms.txt](https://swampys.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://swampys.gitbook.io/docs/resources/voting-system/translation.md).

# Translation

{% stepper %}
{% step %}

### Step 1: Adding a New Language

* **Create a New Translation File**
  * **Navigate to the `locales/` Folder:** Go to the `locales/` folder within your resource directory.
  * **Create a New JSON File:** Create a new JSON file and name it using the language code for the new language (for example, `it.json` for Italian).
* **Copy the Structure from an Existing Translation File**
  * **Use `en.json` as a Template:** Open the existing `en.json` file and copy its entire structure.
    * You’ll be using this structure as a template for your new translation file.
  * **Add Translations:** Translate all the key-value pairs from `en.json` into your desired language (e.g., `it.json` for Italian).
    {% endstep %}

{% step %}

### Step 2: Update Configuration

**Set the Default Language**

* **Change `Config.DefaultLocale`:** If you want your resource to default to the new language (for example, Italian), change the `Config.DefaultLocale` in `config.lua`:

  ```lua
  Config.Locale = 'it' -- 'en' or 'fr'
  ```

{% endstep %}

{% step %}

### Important Points

* **Ensure All Keys Are Translated:** Make sure that every key in the `en.json` file is translated in your new language file (it`.json`). The system will use these key-value pairs to load and display translated content.
* **Translations are Loaded Automatically:** Translations are automatically loaded through the `LoadResourceFile` function and the `json.decode` method.
* **Format:** Translation files must be in JSON format for the system to correctly read and process the translations.
* **Restart Your Resource:** After adding the new language and updating the configuration, restart your resource for the changes to take effect.
  {% endstep %}
  {% endstepper %}
