# Starting

We have developed a translation library where you can build your nested dynamic texts.

> Surely you have ever needed to have a text in different languages, but were confused about how to implement it, that's ok, we had the same problem.

{% hint style="info" %}
To put this into context, let's look at a basic usage example.
{% endhint %}

```typescript
import { Locale } from '@/core/libs/i18n.lib';

const locale = new Locale('en', ['en'], 'locales');

const text = locale.translate('hello', '{YOUR_NAME}');
// output: Hi Niro Health
```

This is the simplest mode to use, very good for inserting into test files.

> Let's understand how this text was generated.

When we instantiate the 'Locale' class, all languages that do not have their '.json' files in the given folder ('locales' - by default) will be created with a 'hello' property set for testing.

{% code title="src/core/locales/en.json" %}

```json
{
  "hello": "Hi $1"
}
```

{% endcode %}

> The use of variables can be done using the identifier '$' followed by a number, for example '$1'.

We can invoke the 'translate' method to bring in our formatted text.

```typescript
locale.translate('hello', 'GuilhermeSantos001');
// output: Hi GuilhermeSantos001
```

Notice that the first argument of the method is the property containing the text and the rest of the arguments are the variables that will be used instead of the '$' identifiers. The reason we use identifiers next to numbers is to maintain sequential referencing, i.e., the first variable will be associated with '$1', the second variable will be associated with '$2', and so on.

{% hint style="success" %}
With this you already structure your texts of simple complexity.
{% endhint %}


---

# 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://guilhermesantos.gitbook.io/niro-health/locale-i18n/starting.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.
