@andreazorzi/textarealocalizer
v1.0.7
Published
Transform your simple textarea into a localizable one
Downloads
53
Maintainers
Readme
TextareaLocalizer
Transform your simple textarea into a localizable one.
Install
npm i @andreazorzi/textarealocalizer
Usage
app.js
// TextareaLocalizer
import TextareaLocalizer from "@andreazorzi/textarealocalizer";
window.TextareaLocalizer = TextareaLocalizer;
app.css
@import "@andreazorzi/textarealocalizer/textarea-localizer.css";
HTML
<textarea id="textarea"></textarea>
<script>
let options = {
"it": "Ciao",
"en": "Hello",
"de": "Hallo",
}
let textarea = new TextareaLocalizer("#textarea", options)
</script>
Options List
{
default_language: null, // Set the language to show by default
texts: { // Set the texts, the keys are the available languages
"it": "",
"en": "",
"de": "",
"fr": "",
"ru": "",
"at": "",
"ch": "",
"es": "",
"ie": "",
},
languages_icons: {
"it": "path/to/asset.png"
},
custom_classes: { // Set the custom classes for each elements
textarea: "",
}
}
Methods
// Get all plugin languages
getAllLanguages()
// Get available languages
getLanguages()
// Switch language
changeLanguage(lang)
// Get all languages values
getValues()
// Get the value of a single language
getValue(lang)