# Prodap Lore Locale

Package used to perform the internationalization of Lore.

See below how to search for specific localization and translation according to the key:

# Installation

This is a [Node.js](https://nodejs.org/download/release/latest/) library available through the [npm](https://www.npmjs.com/) registry.
Before installing, download and install [Node.js](https://nodejs.org/download/release/latest/). Node.js 18.10.0 or higher is required.

If this is a brand new project, make sure you create a `package.json` first with the command [`npm init`](https://docs.npmjs.com/creating-a-package-json-file).

Installation is done using the command [`yarn add`](https://classic.yarnpkg.com/lang/en/docs/cli/add/) or [`npm install`](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):

```bash
$ yarn add prodap-lore-locale
```

or

```bash
$ npm install prodap-lore-locale
```

# Usage

Below are some ways to get the locale information contained in this library:

## Without the locale

Without passing the locale the class will return all locales.

```js
import { Locales } from 'prodap-lore-locale'

const locales = new Locales()

console.log(getLocales) // { "en-US": { "hello": "Hello", ... }, "pt-BR": { "hello": "Olá", ... } }
```

## Passing the locale

Passing the locale the class will return the corresponding locale.

```js
import { Locales } from 'prodap-lore-locale'

const locales = new Locales({ locale: 'pt-BR' })

console.log(getLocales) // { "pt-BR": { "hello": "Olá", ... } }
```

## Looking for a specific translation

When searching for a specific translation, simply enter the corresponding key.

```js
import { Locales } from 'prodap-lore-locale'

const locales = new Locales({ locale: 'pt-BR' })
const hello = locales.translate('hello') // { "hello": "Olá" }

console.log(hello) // Olá
```

## Looking for a specific translation and replace

When looking for a specific translation and want to replace some value, just type the corresponding key and use replace.

```js
import { Locales } from 'prodap-lore-locale'

const locales = new Locales({ locale: 'pt-BR' })
const helloPeople = locales.translate('hello_people').replace('{{VALUE}}', 'Lore') // { "hello_people": "Olá {{VALUE}}" }

console.log(helloPeople) // Olá Lore
```

## Get current library location

In this way it is possible to obtain the current library location.

```js
import { Locales } from 'prodap-lore-locale'

const locales = new Locales({ locale: 'pt-BR' })
const getCurrentLocale = locales.getCurrentLocale()

console.log(getCurrentLocale) // pt-BR
```

## Get library locations

In this way it is possible to obtain the library locations.

```js
import { Locales } from 'prodap-lore-locale'

const locales = new Locales()
const getLocales = locales.getLocales()

console.log(getLocales) // [ "en-US", "pt-BR", ... ]
```
