JSPM

tlabels

1.2.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q18450F
  • License ISC

Translate UI Labels

Package Exports

  • tlabels
  • tlabels/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tlabels) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Translated Labels (TLBS)

Get custom translations to your app easily!

Installation and Initialization

  • Use npm i tlabels to install
  • First, import the libary...
import tLabels from 'tlabels';
  • Then initialize passing the language to use by default and the path to save the json files.
const labels = tLabels('en', 'path/to/save/files/json');

Usage guide

  • To CREATE or EDIT a label, use the method setLabel passing the label name, the label value and the language to use.
await labels.insertOrEdit('hello_world', 'hello world', 'en');
  • To GET a specific label value, use the method getLabel passing the label name and the language to use (optional).
let label = await lbs.get('hello_world');
  • To DELETE one label use the method deleteLabel passing just the label name.
await lbs.delete('hello_world');
  • To check IF EXIST if exist a label, use the method exist passing the label name.
let labelExist = await lbs.itExist('hello_world');
  • To get CURRENT LANGUAGE use the method getLanguage without parameters (is not async).
let language = lbs.getLanguage();
  • To CHANGE LANGUAGE use the method setLanguage passing the language to use (is not async).
lbs.setLanguage('pt');

Note: The name of the labels must be as another_name and not as another name or another-name. This will turn into a javascript object and json as well, those rules prevent the library from breaking.