> For the complete documentation index, see [llms.txt](https://code-after-sex.gitbook.io/script-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://code-after-sex.gitbook.io/script-documentation/cas-shooting-range/languages.md).

# Languages and Translation

Translate the RedM Shooting Range & Competition script: one language file for the menu, HUD, prompts, notifications and server messages, with no rebuild needed.

Every word a player sees comes from one file: the menu, the match HUD, the prompts, the notifications, the server messages, and the names of ranges, modes, targets, weapons, divisions, challenges and the tournament. English is included in `locales/en.lua`.

The menu asks the server for its texts every time it loads, so a translation never needs a rebuild of the interface.

## Switching language

```lua
Config.Locale = 'en'
```

Set it to the code of any file in `locales/` and restart the resource.

## Adding a language

1. Copy `locales/en.lua` to a new file, for example `locales/de.lua`.
2. At the top, change `Locales['en']` to `Locales['de']`.
3. Translate the values. Leave the keys as they are.
4. Set `Config.Locale = 'de'` and restart.

Every file in `locales/` is loaded automatically. Any key missing from your file falls back to English, so you can translate a little at a time.

## How the file is organised

| Keys start with | Used for                                                                                               |
| --------------- | ------------------------------------------------------------------------------------------------------ |
| `data.`         | Names of ranges, modes, targets, weapons, currencies, divisions, challenges, boards and the tournament |
| `ui.`           | The menu and the match HUD                                                                             |
| `cl.`           | Prompts and notices from the client                                                                    |
| `srv.`          | Notifications, results and server messages                                                             |

## Placeholders

Words in braces are filled in by the script. Keep them exactly as they are, in whatever place the sentence needs:

```lua
['srv.admin.probeSaved'] = '{id} saved: {ahead} m clear ahead.',
```

## Plurals

Keys that end in `.one` and `.other` come in pairs. `.one` is used when the number is 1, `.other` for every other number:

```lua
['ui.play.liveNow.one'] = '{n} match live now',
['ui.play.liveNow.other'] = '{n} matches live now',
```

## Names you will probably want to change

| Key                                    | Default                              |
| -------------------------------------- | ------------------------------------ |
| `data.tournament.name`                 | Blackwater Autumn Shootout           |
| `data.blip.name`                       | Shooting Range                       |
| `data.currency.custom.label`           | Range Tokens                         |
| `data.arena.<id>.name` and `.region`   | The range names and regions          |
| `data.challenge.<id>.name` and `.desc` | The challenge names and descriptions |
| `data.division.<id>`                   | The division names                   |

## The menu's own copy

`web/src/data/locale-en.js` is a copy of the English texts that the menu uses only when it is opened in a web browser for editing. In game it is never used. You do not need to translate it.
