# basajs

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

Latest version **2.0.0** (published 2023-05-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install basajs
pnpm add basajs
yarn add basajs
bun add basajs
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-05-04 |
| First published | 2023-02-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | JstnLT |
| Maintainers | jastinlt |

## Links

- npm: https://www.npmjs.com/package/basajs
- Repository: https://github.com/JastinXyz/basa
- Homepage: https://github.com/JastinXyz/basa#readme
- Issues: https://github.com/JastinXyz/basa/issues
- npm.io page: https://npm.io/package/basajs

## Recent versions

- 2.0.0 (latest) — 2023-05-04
- 1.0.1 — 2023-02-19
- 1.0.0 — 2023-02-19

## README

# Basajs

a javascript library that allows your website to be multi-language with ease of use.

## Installation

Add script in the `<head>`:
```html
<script src="https://unpkg.com/basajs@latest/dist/basa.js"></script>
```

## Use It

### Basic
```html
<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
```js
const dict = {
    hello: {
        top: {
            id: "halo",
            en: "hello"
        }
    }
}
```

use it with
```html
<p data-basa="hello.top"></p>
```

## Default Settings

```js
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
});
```

---
_Source: https://npm.io/package/basajs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
