# 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](/send-email.md)

## 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>" %}


---

# 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://documentation.mailhub.sh/internationalization.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.
