javascript - 本地语言在 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>
最初我认为它是由于空白,但这也无法解决问题。
解决方案
你很接近就像
decodeURI(row)
下面这样使用:
source: ["first","second",decodeURI("वित्त वर्ष के लिए")]
推荐阅读
- excel - 使用同一行中不同列的结果
- python - 如何使用 apache-beam 读取数据帧
- javascript - 如何在 React.js 的 return 方法中编写 JS 代码
- go - Go 运行时错误:恐慌:运行时错误:无效的内存地址或 nil 指针取消引用
- python - 使用分类嵌入器包时出现问题
- python - 是否可以在端到端测试中使用 Selenium + Webdriver 模拟语音输入?
- git - 提交日历与 PC 时间不同步
- sql - postgresql 连接两个没有关系的表
- reactjs - 由于 eslint 导入/no-webpack-loader-syntax,CRA 无法构建
- powershell - 创建没有密码的 SecretStore 保险库