A Javascript library for localization and globalization to make any website multilinguil with ease
npm install @localjs/localjsbash
npm i @localjs/localjs
`
Alternatively, you can use the following CDN link to include LocalJS directly in your HTML file:
`html
// JSDeliver
`
`html
// unpkg
`
Usage
$3
To start using LocalJS, follow these steps:
Include the LocalJS script in your HTML file:
`html
`
1. Add the translate attribute to the HTML elements you want to localize.
`html
Sloka of the Day
Today's sloka is a beautiful verse.
`
1. Initialize the library with the desired translations and language selector. For example:
`html
`
Functions
The LocalJS library provides the following methods:
$3
Initialize the library with the language and translations.
- language (string): language id
$3
Update the localization with a new language and translations.
- language (string): language id
Supported Languages
LocalJS supports multiple languages. You can add any language translations you want by providing the language code and corresponding translations.
#### Example
| Language | Code |
| ---------- | ---- |
| English | en |
| Telugu | te |
| Hindi | hi |
| Tamil | ta |
| Kannada | kn |
| Malayalam | ml |
| Bengali | bn |
| Gujarati | gu |
| Marathi | mr |
| Punjabi | pa |
| Urdu | ur |
| Spanish | es |
| French | fr |
| German | de |
| Italian | it |
| Portuguese | pt |
| Dutch | nl |
| Russian | ru |
| Japanese | ja |
| Korean | ko |
translations (object): An object containing the translations for the words or phrases you want to replace.
#### Example
Here's an example implementation of LocalJS:
`json
{
"Sloka of the Day": {
"en": "Sloka of the Day",
"hi": "आज का श्लोक",
"te": "నేటి శ్లోకం"
},
"Today's sloka is a beautiful verse": {
"en": "Today's sloka is a beautiful verse",
"hi": "आज का श्लोक एक सुंदर श्लोक है।",
"te": "నేటి శ్లోకం ఒక అందమైన శ్లోకం."
},
"Select Language": {
"en": "Select Language",
"hi": "भाषा चुनें",
"te": "భాషను ఎంచుకోండి"
}
}
`
Demos
$3
`html
LocalJS Example
Sloka of the Day
Today's sloka is a beautiful verse.
`
$3
`html
Localization Example
Sloka of the Day
Today's sloka is a beautiful verse.
Sloka of the Day
Hello
``