# Translations

If you're new to translations then please take a look at our [Twitter thread](https://twitter.com/PetalFramework/status/1496216170084864000) explaining the basics. Also check out:

* the [hex docs for Gettext](https://hexdocs.pm/gettext/Gettext.html)
* a good [blog post](https://phrase.com/blog/posts/i18n-for-phoenix-applications-with-gettext/) explaining Gettext

In a nutshell, you run text that you want translated through the `gettext` function and then add in your translations. These are found in `priv/gettext`. The `.pot` files are auto-generated - you just need to modify the files in the `LC_MESSAGES` folders.

![You should only modify the files in the LC\_MESSAGES folders](/files/yx7AaqzEo69oovd6OINM)

We've tried to implement `gettext` throughout the public facing areas of the boilerplate (we may have missed some places - feel free to point them out to us or a PR would be very helpful).&#x20;

### How to add update your pot/po files after adding more gettexts

When you add new `gettext` calls, your translation files won't show them until this command is run:

```
mix gettext.extract --merge
```

Then go and add your translations to the files in the `LC_MESSAGES` folders for each language.

### How to add/remove languages

Modify the languages in the `confix.exs` file:

{% code title="config.exs" %}

```elixir
config :petal_pro, PetalProWeb.Gettext, allowed_locales: ~w(en fr)

config :petal_pro, :language_options, [
  %{locale: "en", flag: "🇬🇧", label: "English"},
  %{locale: "fr", flag: "🇫🇷", label: "French"}
]
```

{% endcode %}

If you're adding a new language, you'll need to run this (keep in mind `fr` means French - change this to whatever language you're adding - here's [a list of them all](https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html)):

```
mix gettext.merge priv/gettext --locale fr
```

To delete a language, remove it from the config and delete the corresponding folder in `priv/gettext`.&#x20;


---

# 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://docs.petal.build/petal-pro-documentation/v1.5.0/fundamentals/translations.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.
