因為趨勢潮流逼得我們不得不學著看懂简体,更要提供简体的版本以供台灣人口數80倍以上的大陸市場使用。繁简互轉的方式很多,最簡單的可以利用Google的翻譯功能,有些公司更用心,特別先前轉碼(可能慣用詞都轉)再製作简体版本。其實有個方式,利用Jquery函式庫的方法可以幫助您輕輕鬆鬆作到即時的一鍵繁简互轉。
下戴原始檔案
請先到作者gitbub:https://github.com/hustlzp/jquery-s2t下戴jquery.s2t.js。
在<head>...</head>之間加入以下程式碼:<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <!-- jquery.cookie.js --><script src='https://raw.githubusercontent.com/carhartl/jquery-cookie/master/src/jquery.cookie.js' type='text/javascript'/></script> <!-- jquery.s2t.js --><script src='https://raw.githubusercontent.com/hustlzp/jquery-s2t/master/jquery.s2t.js' type='text/javascript'/></script>
放置轉換按鈕
在適當的位置加入轉換按鈕:<button id="btn-s2t">简</button>
javascript語法
最後再啟用javascript內容:<SCRIPT LANGUAGE="JavaScript"> <!-- $(document).ready(function(){ var bodyIsFt = $.cookie("bodyIsFt"); $('#btn-s2t').click(function () { // to simplified if (bodyIsFt == "1") { $.cookie("bodyIsFt", 0, { expires: 365, path: '/'}); bodyIsFt = "0"; $('#btn-s2t').text('简'); $(document.body).t2s(); } else { // to traditional $.cookie("bodyIsFt", 1, { expires: 365, path: '/'}); bodyIsFt = "1"; $('#btn-s2t').text('繁'); $(document.body).s2t(); } }); }); //--> </SCRIPT>
沒有留言:
張貼留言