# Languages

Var Coins Shop ships with FR / EN / ES translations. Adding a language is a 2-step process.

### Configure available languages

In `shared/config.lua`:

```lua
Language = {
  Default = "en",
  Fallback = "en",
  AllowClientSelection = false, -- true = the player can change language from the UI
  Available = {
    fr = { label = "Francais" },
    en = { label = "English" },
    es = { label = "Espanol" },
  }
}
```

| Key                    | Effect                                                  |
| ---------------------- | ------------------------------------------------------- |
| `Default`              | Locale used for new accounts                            |
| `Fallback`             | Locale used when a translation key is missing           |
| `AllowClientSelection` | If false, the player cannot change language from the UI |
| `Available`            | Map of locale code → label shown in UI                  |

### Add a new language

Example: add German.

**Step 1.** Add the entry in `Available`:

```lua
Available = {
  fr = { label = "Francais" },
  en = { label = "English" },
  es = { label = "Espanol" },
  de = { label = "Deutsch" }, -- new
}
```

**Step 2.** In `shared/locales.lua`, copy the existing `en = { ... }` block and translate it:

```lua
de = {
  shop = {
    title = "Cash-Shop",
    -- ...
  },
  errors = {
    insufficientFunds = "Nicht genug Coins.",
    -- ...
  },
}
```

The script will automatically pick up the new locale on resource restart.

### Per-player locale persistence

Each player's locale is stored in `coins_shop_accounts.locale`. It is updated when:

* The player switches language from the UI (only if `AllowClientSelection = true`)
* You call the server event `var-shop:setLocale` from a custom flow

The `localeUpdate` webhook is fired on every change.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.var-fivem.com/coins-shop/configuration/languages.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
