prodap-lore-locale
TypeScript icon, indicating that this package has built-in type declarations

0.9.2 • Public • Published

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 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:

$ yarn add prodap-lore-locale

or

$ 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.

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.

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.

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.

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.

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.

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

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

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

Dependencies (0)

    Dev Dependencies (16)

    Package Sidebar

    Install

    npm i prodap-lore-locale

    Weekly Downloads

    220

    Version

    0.9.2

    License

    MIT

    Unpacked Size

    1.3 MB

    Total Files

    27

    Last publish

    Collaborators

    • amarcosos
    • andretertuliano
    • amanda.souza
    • adrianopb
    • ana.gouvea