> 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-advanced-gang/translation/adding-a-language.md).

# Adding a language

Add a language to CAS Advanced Gang System: copy the English file, change the code, translate, select it, placeholders and partial translations.

{% stepper %}
{% step %}

### Copy the English file

Copy `locales/en.lua` to `locales/<code>.lua`, for example `locales/es.lua`. The manifest loads every file in `locales/`, so there's nothing to register.
{% endstep %}

{% step %}

### Change the code

In the new file, change the table line to your code:

```lua
Locales['es'] = {
```

{% endstep %}

{% step %}

### Translate the text

Translate the text after each `=`. Keys stay exactly as they are.

```lua
['title.camp_claimed'] = 'Campamento reclamado',
```

Set the three `fmt.` keys to your language's money style. See [Languages](/script-documentation/cas-advanced-gang/translation/languages.md#money-formatting).
{% endstep %}

{% step %}

### Select it

```lua
Config.Locale = 'es'
```

Restart the resource.
{% endstep %}
{% endstepper %}

## Placeholders

Keep every `%s`, `%d` and `%.2f` in the same order. They're filled with names, amounts and counts in the order they appear.

```lua
['msg.has_been_asked_to_ride_with'] = '%s has been asked to ride with %s.',
```

* A literal percent sign is written `%%`, for example `'Freshness %d%%'`.
* A line whose placeholders don't match prints one console line naming the key, and shows the text unfilled. It never stops the resource.

## Partial translations

A key you leave out falls back to English, never a blank. You can ship a partial translation and finish it later.

## The interface's built-in English

`web/src/data/strings.en.js` is the English table built into the interface, so it has text before the game sends any. Translators never touch it: in game it's replaced by the locale file.
