> For the complete documentation index, see [llms.txt](https://docs.mooi.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mooi.cloud/getting-started.md).

# Getting Started

To keep things simple, we will start with an example that does depend on any specific framework just yet (we will cover this later on in [Supported Frameworks](/guides/supported-frameworks.md)).

{% hint style="info" %}
**Before you start**

To use *mooi* you would need an OpenAI API key thas has access to GPT4.
{% endhint %}

### Installation

Simply run:

```
npm i -g mooi-cli
```

{% hint style="info" %}
If you don't have `npm` installed, you can get it from the [official website](https://nodejs.org/en/download)
{% endhint %}

### Define text that needs translation

Let's assume that we are working on an app that shows a `Hello World` message on its main page. We would want this to be available in English, German, and Spanish.

Let's start by creating a `mooi` directory:

```bash
mkdir mooi
```

Inside, define a `translations.yaml` file that will be our source of truth for all product texts:

```yaml
# mooi/translations.yaml

languages: [de, es]          # German and Spanish, and we already covering English in this file
entries:
  - key: main_page_title     # We will need this key later when we will be referring to our copy from code
    value: Hello World       # The actual text that we want to translate
    description: A message shown on the main page of the app
```

{% hint style="info" %}
Take a closer look at the `description` field - this is the main superpower of *mooi* compared to other machine translators. AI will take this description into account when&#x20;
{% endhint %}

### Translate it!

To start the translation, run:

```bash
npx mooi-cli translate --openAiKey {YOUR OPENAI API KEY}
```

Once the command completes, you will see results in `mooi/translations/` folder.&#x20;

### Output Format

That is great, however, we are only halfway there. One could parse the output `yaml` files to use it in their project, but there is a better way. *mooi* provides a way to output translations in whatever format you desire by leveraging [HandlebarJS framework](https://handlebarsjs.com/guide/#what-is-handlebars).

Let's imagine that we would like to have our translations to be stored in a bunch of JSON files (one file per language) called `translations_en.json`, `translations_de.json`, etc. And we would like these files to look something like this:

```json
{
    "main_page_title": "Hallo Welt"
}
```

To achieve that, define a `mooi/config.yaml` file:

```yaml
formats:
  - outputPath: outputs/translations_{{languageCode}}.json
    format: |
      {
      {{#each translations}}
        "{{key}}": "{{{value}}}"{{#unless @last}},{{/unless}}
      {{/each}}
      }
```

Now just run `mooi-cli` again and you will see the output being written into `outputs` folder (that we have configured above):

```bash
npx mooi-cli translate --openAiKey {YOUR OPENAI API KEY}
```

{% hint style="info" %}
Do not hesitate to re-run `mooi-cli` as many times as you need. It keeps track of values that were already translated and won't translate them again, so you are not risking incurring any additional costs.
{% endhint %}

You can refer to [Supported Frameworks](/guides/supported-frameworks.md) section for pre-made recipes on how to integrate *mooi* with your specific framework.

{% content-ref url="/pages/J5ZemYnUqqZb1lXWO8zy" %}
[Supported Frameworks](/guides/supported-frameworks.md)
{% endcontent-ref %}
