Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jang

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

jang

For client-side language text

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

jang

For client-side language text.

Installation

$ npm install jang

Usage


<!-- html lang attribute default language -->

<!DOCTYPE html>
<html lang="tr">

<head>
    <meta charset="utf-8" />
</head>

<body>
    <jang text="language"></jang>
    <button id="changeBtn" jang="title:title;">
        <jang text="change.title"></jang>
    </button>

    <script src="./index.build.min.js"></script>
</body>

</html>

index.js file


const jang = require("jang");
const en = require('./locales/en.js');
const tr = require('./locales/tr.js');

jang.add('en', en);
jang.add([
    { name: 'tr', value: tr }
]);

// html lang attribute is default language or if it doesn't exist, first added language is default
jang.refresh();

jang.onChange(function (name, value) {
    console.log('current language: ' + name);
});

document.getElementById("changeBtn").addEventListener("click", function (e) {
    jang.set(jang.current == 'tr' ? 'en' : 'tr');
});

document.getElementById("addBtn").addEventListener("click", function (e) {
    var div = document.createElement('div');
    div.innerHTML = `<jang text="language"></jang> 
        <button jang="title:new.title;"> <jang text="new.title"></jang> </button>`;
    document.querySelector('body').append(div);
    jang.refresh();
});

index.build.js file

index.build.js file is generated from index.js with libraries like browserify or babel or parcel or webpack.

Build Sample

tr.js file


module.exports = {
    title: "Türkçe",
}

en.js file


module.exports = {
    title: "Engilish",
}

Examples

Basic Usage

This example shows the most basic way of usage.

License

This software is free to use under the JosephUz. See the LICENSE file for license text and copyright information.

Keywords

FAQs

Package last updated on 15 Nov 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc