Skip to content

Simple client-side translator using jQuery, javascript, and a single .json file for all the text.

Notifications You must be signed in to change notification settings

gianlucahmd/jquery-simple-translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jQuery simple translator

Simple client-side translator using jQuery, javascript, and a single .json file for all the text.

Advantages:

  • Translation happens client-side: no browser refresh
  • All text, in all languages is in a unique json file: easier to manage translations (most of all if made by other non-technical people people...) and implement changes to all languages.

Disadvantages:

  • In pages with a lot of text, having all the text in one file can get messy. In this case it's recommended to use separated files, like this guy did.

Usage:

  • include jQuery
  • include jquery-simple-translator.js (after jQuery)
  • add a text_id tag to every part of your html which includes text
  • create a text.json file with your text, using as keys the same tags as in text_id, appending and underscore + the language code (example: text_es for spanish).
  • the code automatically detets the language of the user's browser. However, it's good practice to give the user the chance to change it (you never know...). You can do that by making an HTML button or link that calls populate_textfields(JSONtext, 'language_code').

For a full functioning example, check out the index.html and text.json in this repository, or try it using this codepen.

About

Simple client-side translator using jQuery, javascript, and a single .json file for all the text.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages