Transform your simple textarea into a localizable one.
npm i @andreazorzi/textarealocalizer
// TextareaLocalizer
import TextareaLocalizer from "@andreazorzi/textarealocalizer";
window.TextareaLocalizer = TextareaLocalizer;
@import "@andreazorzi/textarealocalizer/textarea-localizer.css";
<textarea id="textarea"></textarea>
<script>
let options = {
"it": "Ciao",
"en": "Hello",
"de": "Hallo",
}
let textarea = new TextareaLocalizer("#textarea", options)
</script>
{
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: "",
}
}
// 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)