Giter VIP home page Giter VIP logo

js-izilang's Introduction

js-izilang

Dynamically change a website language without reloading with only a 10 lines function.

Created by

Ilian Azz, https://ilianazz.com/

Usage

You can find a full example in the index.html file.

Text translation

Just put the "ild" attribute in the tag that you want to change the language. The value must be a key in the LANGS file (of a certain lang). For example :

<h1 ild=welcome> </h1>

With this index.js lang file :

const LANGS = {"fr": {"welcome" : "Bienvenue"}, "en" : {"welcome" : "Welcome"}}

Other translations

By specifying an "ilt" attribute, you can change all of the attributes : value or placeholder for example.

<input type=text name=mail placeholder="" ild=mail ilt=placeholder>

With this index.js lang file :

const LANGS = {"fr": {"mail" : "Adresse mail"}, "en" : {"mail" : "Email address"}}

Saving with cookies

Cookies permit to memorize the user preferences. By navigating in the page, texts will be automatically updated based on the user choice.

Auto diagnostic

Moreover, a diagnostic permit to know if translations are missing in the js lang file. Just call the funciton after importing the Js script. A 5px red border will be set around missing translation elements. The missing translation languages will be shown in the HTML.

The text content in the html file can be empty, an initialiastion is done when loading the page.

js-izilang's People

Contributors

ilianazz avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.