码迷,mamicode.com
首页 > Web开发 > 详细

translate.js

时间:2015-11-25 18:40:56      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:

http://www.openxrest.com/translatejs/index.html

translate.js

translate.js is a jQuery plugin to translate text in the client side.

 

Usage: translate entire page

Step 1: include JQuery and translate.js in your page

  • <script src="jquery.js"/> <script src="jquery.translate.js"/>

Step 2: every text you want translated include the trn class

  • <span class="trn">text to translate</span>

Step 3: create your dictionary

  • var dict = { "Home": { pt: "Início" }, "Download plugin": { pt: "Descarregar plugin", en: "Download plugin" } }

Step 4: initialize the plugin and translate the entire page body

var translator = $(‘body‘).translate({lang: "en", t: dict}); //use English

Step 5: change to another language

  • translator.lang("pt"); //change to Portuguese

Step 6: try it

 

 

Usage: translate a string

After you initialize the component you can translate a string

  • var translation = translator.get("Home"); //returns "Início"

 

 

 

 

 

 

 

 

 

xxxxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxxxxxxxxxxxx

translate.js

标签:

原文地址:http://www.cnblogs.com/xgqfrms/p/4995162.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!