> For the complete documentation index, see [llms.txt](https://edseries-plugins.gitbook.io/p/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://edseries-plugins.gitbook.io/p/edlang/features/language-detection.md).

# Language detection

A player who has not picked a language with `/lang` gets one automatically. `detection` in config.yml lists the methods, first match wins:

```yaml
detection:
  - client
  - ip
```

* **client**: the player's Minecraft language. It is mapped through `client-locales`, or by its first two letters (`es_mx` becomes `es`), and only used when that language exists in `lang/`. When the player changes their Minecraft language in the options, EdLang follows it (once, half a second after the last change, so a client flipping it quickly doesn't cause lag).
* **ip**: the country of the player's IP, mapped through `countries`. The lookup runs before the player joins, off the main thread.

With `client` first, the country is only used when the client's language has no lang folder (an English-speaking server with a French client and no `lang/fr/`, for instance, falls back to the country).

Nothing matched: the `default-language`.

## GeoIP

```yaml
geoip:
  enabled: true
  file: country.mmdb
  auto-download: true
  max-age-days: 35
```

EdLang downloads the free DB-IP "IP to Country Lite" database (CC BY 4.0, <https://db-ip.com>) when the file is missing or older than `max-age-days`, and updates it in the background. You can use your own MaxMind-format file instead (GeoLite2-Country works): set `auto-download: false` and put it at `plugins/EdLang/<file>`.

## Countries and client languages

```yaml
countries:
  es: [ES, MX, AR, CO, CL]      # ISO country codes -> language code
  pt: [BR, PT]
client-locales:
  pt: [pt_br, pt_pt]            # Minecraft language ids -> language code
  nl: [nl_nl, nl_be, af_za]
```

## Players choose

* `/lang <code>` picks a language and keeps it (stored, also across servers with MySQL).
* `/lang auto` goes back to automatic.
* `change-cooldown-seconds` (2 by default) stops players from spamming changes.

## First-join picker

```yaml
ask-on-first-join:
  enabled: true
  only-when-unsure: true
  delay-ticks: 100
```

On a player's first join, the first-join menu (`menus/first-join.yml`) opens a few seconds after they join. With `only-when-unsure: true` it only opens when their country and their Minecraft language point to different languages (a Spanish IP with an English client); with `false` every new player is asked. It is never shown again after that join, and never to a player who already picked a language.
