# Internationalization

Internationalization can be a tedious task for your application and even more so for your emails\
Learn how to simplify the process

## How it works?

The i18n works similar to what you are used to\
The patterns are similar to on [Next-intl](https://next-intl-docs.vercel.app/)

### Default language

You can set a default language.\
If a default language is configured and you omit the `language` parameter when you call, or if the specified language is not available, the system will use the default language.

If no default language is set, the system will use the language specified when you call. If that language is not available, no translation file will be applied.

#### [How to send email with language? Check it out](https://documentation.mailhub.sh/send-email)

## Translations file

You can add a language in the template editor in your dashboard\
Once the language is added, you can edit the translation file.

The expected format is JSON

### Basic

```json
{
  "hello": "Hello",
}
```

### Advanced

```json
{
  "hello": "Hello { user.firstname }",
}
```

## Use translation

### Basic

```html
<h1>{{ t('hello') }}</h1>
```

{% code title="Output" %}

```html
<h1>Hello</h1>
```

{% endcode %}

### Advanced

```html
<h1>{{ t('hello', { user: { firstname: 'John' } }) }}</h1>
```

{% code title="Output" %}

```html
<h1>Hello John</h1>
```

{% endcode %}

#### Utiliser les variables de la template

{% code title="Variables" %}

```json
{
  "user": {
    "name": "John"
  }
}
```

{% endcode %}

```html
h1>{{ t('hello', { firstname: page.user.firstname }) }}</h1>
```

{% code title="Output" %}

```html
<h1>Hello John</h1>
```

{% endcode %}

## Full demo

{% embed url="<https://youtu.be/CtRSTiK9Mkc>" %}
