npm.io
1.0.13 • Published 11 months ago

@andreazorzi/textarealocalizer

Licence
MIT
Version
1.0.13
Deps
0
Size
134 kB
Vulns
0
Weekly
0

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)

Keywords