> 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/getting-started/how-translations-work.md).

# How translations work

Two things make a text show in every player's language:

1. **A placeholder** where the text was, in any plugin's config: `{lang:shop.title}` or `%lang_shop.title%`.
2. **A value for that key** in each language's files: `shop.title` is `Shop` in English, `Tienda` in Spanish.

EdLang replaces the placeholder with the value in the language of the player who sees it. A key a language doesn't have uses the default language's value (`default-language` in config.yml). A key no language has stays in the text as written, so a typo is easy to spot (and `/edlang missing` lists it).

## The folder layout

Every language is a **folder** inside `plugins/EdLang/lang/`, named by its code: the code players type in `/lang <code>`. Inside it, put as many `.yml` files as you like, in as many subfolders as you like. Every file of a language is read and merged into one set of keys.

```
plugins/EdLang/lang/
  en/
    edlang.yml                    EdLang's own messages and menu texts
    server/
      scoreboard.yml
      tab.yml
      holograms.yml
      messages.yml
      plugins/
        crates.yml
        shop/
          categories.yml
          items.yml
  es/
    edlang.yml
    server/
      scoreboard.yml
      ...
  de/
    ...
```

The structure is up to you: by plugin, by feature, one big file, or anything in between. It is easiest to keep the same files in every language, so `lang/es/server/tab.yml` holds the Spanish of `lang/en/server/tab.yml`.

## The key rule

**A key is its nested YAML keys joined with dots. Folder and file names are never part of the key.**

```yaml
# lang/en/server/scoreboard.yml
scoreboard:
  title: '&b&lMY SERVER'
  lines:
    balance: '&7Balance: &a{0}'
```

These are the keys `scoreboard.title` and `scoreboard.lines.balance`, used as `{lang:scoreboard.title}`. The file could be `lang/en/scoreboard.yml`, `lang/en/server/scoreboard.yml` or `lang/en/anything/else.yml`: the keys are the same. You can move and rename files at any time without touching a single placeholder.

### key-prefix

A file may start with a top-level `key-prefix:`, which puts every key of that file under a common start. It saves repeating the same top levels in a file that only holds one plugin's texts:

```yaml
# lang/en/server/plugins/crates.yml
key-prefix: crates

vote:
  name: '&a&lVote Crate'      # the key crates.vote.name
opened: '&7You opened a {0}'  # the key crates.opened
```

`key-prefix` itself is not a key, and it only applies to the file it is in.

## Values

* A value is text with `&` colour codes, `&#RRGGBB` hex colours or MiniMessage tags (`<red>`, `<gradient:...>`), see `placeholders.value-format`.
* A **list** is a multi-line value: in an item lore it becomes several lore lines, in chat several lines.
* `{0}`, `{1}`... take the placeholder's arguments, `{name}` takes a named argument. See [Placeholders](/p/edlang/getting-started/placeholders.md).
* A value may contain other placeholders: `'&8[%lang_server.name%&8]'`.

## Read order and duplicate keys

A language's files are read in this order:

1. the flat file `lang/<code>.yml`, if there is one (the EdLang 1 layout);
2. every file in the folder `lang/<code>/`, by path in alphabetical order (`lang/es/menus/shop.yml` before `lang/es/server/tab.yml`).

When the same key is in two files of one language, the console shows a warning naming **both** files, and the file read **later** wins:

```
[EdLang] Duplicate lang key: 'shop.title' is in lang/es/menus/shop.yml and lang/es/server/shop.yml (the second one is used)
```

The first 15 duplicates of a language are listed, then a count of the rest.

## Switching a file off

Files and folders whose name starts with `_` or `.` are skipped: rename `holograms.yml` to `_holograms.yml` (or a folder `plugins` to `_plugins`) to switch it off without deleting it.

## EdLang 1 flat files

The old single-file layout `lang/<code>.yml` still loads. When both `lang/es.yml` and the folder `lang/es/` exist, they are merged into one language (the folder's files are read after the flat file, so the folder wins on a duplicate). You can move keys from the flat file into folders a bit at a time.

## A language's name and flag

Each language should have these two keys (EdLang's bundled `edlang.yml` files already do):

```yaml
language:
  name: 'Español'                       # shown in /lang and the menus
  icon: 'texture-eyJ0ZXh0dXJlcyI6...'   # its menu item: a material or texture-<base64 head texture>
```

## Adding a language

1. Create the folder, e.g. `lang/nl/`.
2. Copy the files of your default language into it and translate the values (keep the keys).
3. Add `language.name` (and `language.icon` if you want a flag head).
4. `/edlang reload`. The language is now in `/lang`, and players whose Minecraft language is Dutch get it automatically.

EdLang's own texts (`edlang.*`) are bundled in en, es, de, fr, pt and it. For any other language they come from the default language until you translate them in `lang/<code>/edlang.yml`.

## Reloading

`/edlang reload` reads every lang file again, including **new files and new folders** (a new language), in the background; the new texts switch in at once when it is done, and players' holograms, items and scoreboards are sent again in the new texts. The server does not freeze, even with hundreds of thousands of lines.

## Finding what is missing

`/edlang missing <code>` lists the keys the default language has and `<code>` lacks (the first 15 in chat, all of them in `plugins/EdLang/missing-<code>.txt`), and the keys that are used in a placeholder somewhere but exist in no language.

## First install

On the very first start (no `lang/` folder yet) EdLang writes its own texts for six languages plus example files in `lang/en/server/` and `lang/es/server/` (scoreboard, tab list, holograms, messages, a crates plugin with `key-prefix`). After that, EdLang never writes into `lang/` again: the files are yours. Delete the examples whenever you like.
