Skip to content

HackJack-101/i18n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

i18n

Micro i18n library for Javascript

Install

Script

Just download i18n.js and add it on your html page.

<!DOCTYPE HTML>
<html>
  <head>
  ...
  <script src="path/to/i18n.js" type="text/javascript"></script>
  </head>
  ...
</html>

Folder and files

Create your translation files in locales folder like this:

  • /locales/en.json
  • /locales/fr.json
  • /locales/es.json
  • /locales/de.json

Usage

In your main script :

window.addEventListener('load', function () {
  int = new i18n();
  int.translate();
});

Fill your json with a structure like this :

{
  "key": "translation"
}

And, add the attribute data-i18n on elements you want to translate :

<span data-i18n="key"></span>

Example

Live Example

Browser compatibility

  • Chrome: 1
  • Firefox: 3.5
  • Internet Explorer: 9
  • Opera: 10
  • Safari: 3.2

Releases

Packages

Contributors

Languages