基本信息
源码名称:js 多语言包切换(国际化),i18n示例源码
源码大小:0.03M
文件格式:.zip
开发语言:js
更新时间:2019-02-13
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍



<!DOCTYPE html>
<html>
  <head>
      <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
      <script src="http://design.yyuap.com/static/jquery/jquery-1.9.1.min.js"></script>
      <script src="./i18next-1.7.7.min.js"></script>
  </head>
  <body>
    <div data-i18n="title"></div>
    <input data-i18n="[placeholder]placeholder" type="text">
    <p data-i18n="para"></p>
    <button class="lang" data-lang="EN">EngLish</button>
    <button class="lang" data-lang="CN">中文</button>
    <script>
        var resources = {
            "CN":{
                "translation":{
                    "title":"标题",
                    "placeholder":"输入名字",
                    "para":"一段自我介绍"
                }
            },
            "EN":{
                "translation":{
                    "title":"Title",
                    "placeholder":"Enter Name",
                    "para":"some about my story"
                }
            }
        }

        $(document).ready(function(){
            i18n.init({
                'lng':'EN',
                'resStore':resources
            },function(t){
                $(document).i18n();
            })

            $('.lang').click(function(){
                var lang = $(this).attr('data-lang');
                i18n.init({
                    'lng':lang
                },function(){
                    $(document).i18n();
                })
            })


        })

    </script>
 </body>
</html>