# Control Panel Translations

Statamic's Control Panel is currently available in 28 languages. We always welcome new translations!

## Configuration

Set which language you want to use by default in `config/app.php`. You may also choose a fallback locale in case new content and strings are added to the control panel before an accompanying translation has been updated.

``` php
'locale' => 'es',
'fallback_locale' => 'en',
```

### Per-user override

You can override the translation locale on a per-user basis by setting `locale: {code}` in a given user's preferences (their YAML record).

``` yaml
#  users/nosmo.king@example.com
name: Nosmo King
super: true
preferences:
  locale: en
```

### Available Translations

| Language            | Code    |
|---------------------|---------|
| Arabic              | `ar`    |
| Azerbaijani         | `az`    |
| Czech               | `cs`    |
| Danish              | `da`    |
| German              | `de`    |
| German (Swiss)      | `de_CH` |
| English             | `en`    |
| Spanish             | `es`    |
| Estonian            | `et`    |
| Persian             | `fa`    |
| French              | `fr`    |
| Hungarian           | `hu`    |
| Indonesian          | `id`    |
| Italian             | `it`    |
| Japanese            | `ja`    |
| Malay               | `ms`    |
| Norwegian           | `nb`    |
| Dutch               | `nl`    |
| Polish              | `pl`    |
| Portuguese          | `pt`    |
| Portuguese (Brazil) | `pt_BR` |
| Russian             | `ru`    |
| Slovene             | `sl`    |
| Swedish             | `sv`    |
| Turkish             | `tr`    |
| Ukrainian           | `uk`    |
| Vietnamese          | `vi`    |
| Chinese             | `zh_CN` |
| Chinese (Taiwan)    | `zh_TW` |

_Translations are community contributed so you may find them to be incomplete shortly after an update._

## Translations not covered by Statamic

Although Statamic's translations cover *most* of the strings in the Control Panel, there are a couple of places where Statamic will fallback to your application's translations.

One example of this is on Statamic's authentication pages. Since it's using Laravel's built-in authentication under the hood, translations for any validation errors will be pulled from your app's `lang` or `resources/lang` directory.

To save you manually translating Laravel's strings yourself, you can copy the necessary translations from the community-driven [Laravel-lang](https://github.com/Laravel-Lang/lang/tree/main/locales) repository into your application.

## Contributing a new translation

There are 4 steps.

1. Clone [`statamic/cms`](https://github.com/statamic/cms) locally
2. Run `composer install`
3. Generate a new translation from source files
4. Translate new message files in `lang`
5. Add the language to the [array in CorePreferences](https://github.com/statamic/cms/blob/cce7045e3f0ff418ee6e0a982a3830d604c6b64c/src/Preferences/CorePreferences.php#L56-L82) so it's selectable
6. Commit changes and submit a PR

### Generating translation files

Run the `translator generate` command in the `statamic/cms` project, along with the new language code as an argument. This will generate empty JSON and PHP files in `lang` ready to be translated into the locale of your choice.

You can specify a short 2 character language code (`es`) or the full 4 character regional code (`es_MX`).

_It is recommended that you comply to the [`language code standard`](https://www.science.co.il/language/Codes.php)._

``` shell
php translator generate eo
```

- The JSON file contains all the "short strings" established on the fly with the translation helpers, e.g. `__('Cowabunga')`.
- The PHP files contain longer strings and are well organized by section of the control panel.
- Translatable strings can contain a `|` to separate singular and plurals.
- Translatable strings can contain the `:something` format to indicate a variable.

``` files theme:serendipity-light
lang/
|-- eo/
|   |-- markdown.php
|   |-- messages.php
|   |-- permissions.php
|   |-- validation.php
|-- eo.json
```

:::tip
This command will also update existing files with any changes from recent Statamic releases.
:::

#### Using Google translate

You can get a translation kickstarted with the Google API by passing your API key.

``` shell
php translator generate eo --key=abc123
```

### Using the reviewer

Running the `translator review` command will loop through all the translations showing you the key, the English phrase, and new translated phrase for proofreading. You can enter new translations during this process. You can also use this command to gather new or changed translatable strings after a Statamic update.

``` shell
php translator review eo messages
```
