今天發現一個簡單的實踐多語言的網站方法

https://github.com/dakk/jquery-multilang a simple and fast multilanguage lib for jQuery.

Put the attribute tkey in each element you want to translate:
放 attribute tkey 在每個元素你要翻譯的
<p tkey="string-key-example"></p>

Modify the lang json files, having one translated string for each tkey in each language file:
修改 Lang 資料夾中的json 檔案,每一個Key word 對應所需要翻譯的字。

"string-key-example" : "Example string in English"

Load jquery.js and lang.js at the end of the HTML file:
別忘了要在要翻譯的HTML檔案中加載 Jquery.js and Lang.js檔案

<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="lang.js"></script>

I modified the original file to have language switch
我修改了本來的檔案, 有語言切換器。
http://1drv.ms/1ruLbj1

If you encounter problem, please look at the below link
如果你遇到問題了,可以看這篇
http://tw.gigacircle.com/2555877-1

arrow
arrow
    文章標籤
    language switchjQuery 語言切換
    全站熱搜

    Kenneth 發表在 痞客邦 留言(0) 人氣()