Package used to carry out the internationalization of Lore
Package used to perform the internationalization of Lore.
See below how to search for specific localization and translation according to the key:
This is a Node.js library available through the npm registry.
Before installing, download and install Node.js. 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.
Installation is done using the command yarn add or npm install:
``bash`
$ yarn add prodap-lore-locale
or
`bash`
$ npm install prodap-lore-locale
Below are some ways to get the locale information contained in this library:
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 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á", ... } }
`
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á
`
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
`
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
`
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", ... ]
``