> 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-gunsmith/configuration/localization.md).

# Localization

Translate CAS Gunsmith — pick the language with Config.Locale, add your own language file and translate part, finish, ammo and weapon names.

Every text the script shows comes from a language file in the `locales` folder: notifications, the prompt, the map blip and the whole bench interface. English (`en.json`) and Turkish (`tr.json`) are included.

## Choosing the language

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

Set it to the name of a file in `locales` without `.json`, for example `'tr'`, and restart the resource. The server and every player use the same language.

If a key is missing from the chosen file, its English text from `en.json` is used. If the file does not exist or is not valid JSON, the server console shows `locales/<name>.json not found or not valid JSON, using English.` and everything stays in English.

## Adding a language

1. Copy `locales/en.json` to a new file, for example `locales/de.json`.
2. Translate the values. Leave the keys on the left as they are.
3. Set `Config.Locale = 'de'` and restart the resource.

No build is needed. The interface receives the texts from the server every time the bench opens.

Keep the words in curly braces, such as `{shop}`, `{name}` or `{n}`. The script fills them in. Their order can change to suit the language:

```json
"shop.name": "{shop} Gunsmith",
"date.long": "{month} {day}, 1899",
```

In `tr.json` these are `"{shop} Silahçısı"` and `"{day} {month} 1899"`.

Some keys need a note:

| Key                               | Notes                                                                                                      |
| --------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `lang`                            | The language code, for example `de`. The interface uses it for upper-case letters, such as Turkish i to İ. |
| `date.months`, `date.monthsShort` | The twelve month names, separated by commas.                                                               |
| `fmt.pct`                         | How a percentage is written: `{n}%` or `%{n}`.                                                             |
| `*.one`, `*.other`                | Singular and plural forms of the same sentence. Languages without a plural can use the same text for both. |

## Option names

The names and descriptions of parts, finishes, woods, engravings, carvings, wraps, ammunition and weapons are written in `config.lua`. A language file can translate them by the option's id:

| Key                                       | Config entry                                                             |
| ----------------------------------------- | ------------------------------------------------------------------------ |
| `weapon.<key>`                            | `label` of a weapon in `Config.Weapons`, for example `weapon.boltaction` |
| `part.<id>`, `part.<id>.desc`             | A part option, for example `part.barrel_long`                            |
| `metalPart.<group>.<key>`                 | A row of `Config.MetalParts`, for example `metalPart.longarm.frame`      |
| `metal.<id>`                              | `Config.Metals`                                                          |
| `wood.<id>`                               | `Config.Woods`                                                           |
| `engraving.<id>`                          | `Config.Engravings`                                                      |
| `inlay.<id>`                              | `Config.EngravingMetals`                                                 |
| `carving.<id>`, `carving.<id>.long`       | `Config.Carvings`: the handgun name and the long-gun name                |
| `wrap.<id>`, `wrap.<id>.desc`             | `Config.WrapStyles`                                                      |
| `wrapColor.<id>`                          | `Config.WrapColors`                                                      |
| `ammoType.<ammo>`, `ammoType.<ammo>.desc` | `Config.Ammo`, for example `ammoType.AMMO_REVOLVER`                      |

`tr.json` contains all of them and is a good starting point for another language. An option with no key in the language file keeps its name from `config.lua`. `en.json` has none of these keys, so in English the names in `config.lua` are always used.

If you add an option to `config.lua` or rename one while running Turkish, add or change its key in `tr.json` too, or delete the key so the name from `config.lua` is used.

## Good to know

* The weapon name on the bench comes from the inventory's item label when it has one. The `weapon.<key>` keys are used where the inventory gives no label, and for preset and model names.
* Shop names (`label`) and shop keepers (`keeper`) are taken from `Config.Shops` as they are.
* The first-logged and last-serviced dates are stored with the weapon as text. After a language change, dates written earlier stay in the old language.
