首页 > 解决方案 > 本地语言在 javascript 文件中的页面加载时转换为外来语言

问题描述

我希望我的页面在选择的语言是印地语时以印地语语言显示某些文本。

我的代码:

 function getCookie(cname) {
        var name = cname + "=";
        var decodedCookie = decodeURIComponent(document.cookie);
        var ca = decodedCookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') {
                c = c.substring(1);
            }
            if (c.indexOf(name) == 0) {
                return c.substring(name.length, c.length);
            }
        }
        return "";
    }
    function setCookie(cname, cvalue, exdays) {
        var d = new Date();
        d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
        var expires = "expires=" + d.toGMTString();
        document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
    }


if ((currentUiCluture != null) && (currentUiCluture != undefined) && (currentUiCluture != "")) {
                if (currentUiCluture == 'hi-IN') {
                    $('#AmtFYyear').text(yr  + "वित्त वर्ष के लिए जिलावार अर्जित राशि " + "(करोड़ रुपये में)");                
                }
                if (currentUiCluture == 'en-US') {
                    $('#AmtFYyear').text("District wise Accrued Amount for FY  " + yr + " (Rs in Cr.)");
               }
            }
            else
            {
                 $('#AmtFYyear').text("District wise Accrued Amount for FY  " + yr + " (Rs in Cr.)");           
            }

但是,转换为वितषषषकेलिएलिएलिएलिएजितजितजितजित p>

最初我认为它是由于空白,但这也无法解决问题。

标签: javascriptjquerysharepoint-2013

解决方案


你很接近就像decodeURI(row)下面这样使用:

source: ["first","second",decodeURI("वित्त वर्ष के लिए")]


推荐阅读