Socket
Socket
Sign inDemoInstall

juclientlang

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    juclientlang

For client-side language text


Version published
Weekly downloads
7
increased by16.67%
Maintainers
1
Install size
8.56 kB
Created
Weekly downloads
 

Readme

Source

ju Client Language

For client-side language text.

Installation

$ npm install juclientlang

Usage

Example File Tree

├── node_modules
│ ├── juclientlang
├── page.build.js
├── locales
│ ├── tr.js
│ └── en.js
├── page.html
└── page.js

page.html file


<!-- lang attribute is required! --> 
<!DOCTYPE html>
<html lang="tr">

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

<body>
    <julang text="language"></julang>
    <button id="changeBtn" julang="title:title;">
        <julang text="title"></julang>
    </button>

    <script src="./page.build.js"></script>
</body>

</html>

page.js file


const juLang = require("juclientlang");

const langPath = './locales';

juLang(langPath)
    .then(function () {
        console.log("language loaded.");
    }).catch(function (err) {
        console.log(err.message);
    });

document.addEventListener("juLangChanged", function (e) {
    console.log(e.detail);
});

document.getElementById("changeBtn").addEventListener("click", function (e) {
    var html = document.getElementsByTagName("html")[0];
    if (html.attributes.lang.value == "en")
        html.setAttribute("lang", "tr");
    else
        html.setAttribute("lang", "en");
});

page.build.js file

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

Building Sample

tr.js file


var juLangObject = {
    language: "Türkçe",
    title: "Değiştir"
}

Methods

juLang(languageScriptPath)

With the return of the Promise object, you can capture the completion of the process and errors.

Parameters:

  • languageScriptPath: Path of language javascript files.
juLangChanged Event

If you want to catch events after each change, use

document.addEventListener("juLangChanged", function handle(e) { ... }) 

handle Function Parameters:

  • e.detail: Event result.

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

Last updated on 03 Nov 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc