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 tlabelsto 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
setLabelpassing 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
getLabelpassing the label name and the language to use (optional).
let label = await lbs.get('hello_world');- To DELETE one label use the method
deleteLabelpassing just the label name.
await lbs.delete('hello_world');- To check IF EXIST if exist a label, use the method
existpassing the label name.
let labelExist = await lbs.itExist('hello_world');- To get CURRENT LANGUAGE use the method
getLanguagewithout parameters (is not async).
let language = lbs.getLanguage();- To CHANGE LANGUAGE use the method
setLanguagepassing 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.