New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

basajs

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basajs

a javascript library that allows your website to be multi-language with ease of use.

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Basajs

a javascript library that allows your website to be multi-language with ease of use.

Installation

Add script in the <head>:

<script src="https://unpkg.com/basajs@latest/dist/basa.js"></script>

Use It

Basic

<p data-basa="hello"></p>
<p data-basa="greeting"></p>

<button onclick="Basa.changeLang('id')">id</button>
<button onclick="Basa.changeLang('en')">en</button>

<script>
    const dict = {
        hello: {
            id: "halo",
            en: "hello",
        },
        greeting: {
            id: "selamat datang",
            en: "welcome",
        },
    };

    Basa.init({
        languages: ["id", "en"],
        useLocalStorage: true,
        dictionary: dict,
    });
</script>

Nested

const dict = {
    hello: {
        top: {
            id: "halo",
            en: "hello"
        }
    }
}

use it with

<p data-basa="hello.top"></p>

Default Settings

Basa.init({
    languages: [], // language array
    useLocalStorage: false, // if true, localstorage will store the language in the `lang` key which can be used if the client revisits the page, the language will automatically use the one in localstorage
    addActiveClass: false, // if true, it will add the "active" class to the element with the id being the name of one of the provided languages
    dictionary: {} // translation object
});

FAQs

Package last updated on 04 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts