我可以翻译是/否在布尔开关滑块从jquery?



我有一个带有是/否选项的开关按钮滑块。

以下是html文件
<!DOCTYPE html>
<html lang="en">
<head>
<title>Yes/No or True/False question - Boolean question, jQuery Survey Library Example</title><meta name="viewport" content="width=device-width"/>
<script src="https://unpkg.com/jquery"></script>
<script src="https://unpkg.com/survey-jquery@1.8.58/survey.jquery.min.js"></script>
<link href="https://unpkg.com/survey-core@1.8.58/modern.min.css" type="text/css" rel="stylesheet"/>
<link rel="stylesheet" href="./index.css"></head>
<body>
<div id="surveyElement" style="display:inline-block;width:100%;"></div>
<div id="surveyResult"></div>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>

和下面的javascript文件

Survey
.StylesManager
.applyTheme("modern");
var json = {
questions: [
{
"type": "boolean",
"name": "bool",
"title": "Please answer the question",
"label": "Are you 21 or older?",
"isRequired": true
}
]
};
window.survey = new Survey.Model(json);
survey
.onComplete
.add(function (sender) {
document
.querySelector('#surveyResult')
.textContent = "Result JSON:n" + JSON.stringify(sender.data, null, 3);
});
$("#surveyElement").Survey({model: survey});

我从这里取了代码。

我能把Yes/No翻译成Ja/Nein(德语)吗?没有id。所以我不能用替换函数。有其他可行的方法吗?

您需要像这样使用locale设置:

Survey
.StylesManager
.applyTheme("modern");
var json = {
locale: "de",
questions: [
{
"type": "boolean",
"name": "bool",
"title": "Please answer the question",
"label": "Are you 21 or older?",
"isRequired": true
}
]
};
window.survey = new Survey.Model(json);
survey
.onComplete
.add(function (sender) {
document
.querySelector('#surveyResult')
.textContent = "Result JSON:n" + JSON.stringify(sender.data, null, 3);
});
$("#surveyElement").Survey({model: survey});

这里是你可以使用的本地化列表:https://github.com/surveyjs/surveyjs/tree/master/src/localization

最新更新