我使用 SurveyJS 进行调查。我阅读了 localization 上的示例并实现了它。我可以使用以下方式本地化标题:
"title": {
"default": "During the past week ...",
"de-de": "In der letzten Woche ...",
}
同样的格式适用于
"text"
、"labelTrue"
和 "labelFalse"
。
所以我尝试使用多项选择题的格式:
{
"type": "radiogroup",
"name": "parent_type",
"title": {
"default": "I am...",
"de-de": "Sie sind:",
},
"isRequired": true,
"showOtherItem": true,
"colCount": 1,
"choices": {
"default": ["mother", "father"],
"de-de": ["Mutter", "Vater"],
},
"separateSpecialChoices": true,
"showClearButton": true,
}
我在浏览器 JavaScript 控制台中收到错误:
Uncaught TypeError: this.getFilteredChoices(...).slice is not a function
我还尝试颠倒表格字典顺序:
{
"type": "radiogroup",
"name": "parent_type",
"title": {
"default": "I am:",
"de-de": "Sie sind:",
},
"isRequired": true,
"showOtherItem": true,
"colCount": 1,
"choices": [{
"default": "mother",
"de-de": "Mutter",
}, {
"default": "father",
"de-de": "Vater"
}],
"separateSpecialChoices": true,
"showClearButton": true,
}
这显示了调查,但答案如下:
I am: *
- [object Object]
- [object Object]
- Other (describe):
我不能使用布尔类型,因为有时祖母或叔叔会回答调查。目前,我已经将问题的标题本地化为“Sie Sind:(母亲= Mutter,父亲= Vater)”,但它看起来很糟糕并且降低了答案的可能性。
如何在 SurveyJS 中本地化多项选择题?
我相信选择的目标是每个选择都有一个值,但只是不同的显示文本。这应该有效:
{
"type": "radiogroup",
"name": "parent_type",
"title": {
"default": "I am...",
"de-de": "Sie sind:",
},
"isRequired": true,
"showOtherItem": true,
"colCount": 1,
"choices": [
{
"value": "mother",
"text": { "default": "Mother", "de-de": "Mutter" }
},
{
"value": "father",
"text": { "default": "Father", "de-de": "Vater" }
}
],
"separateSpecialChoices": true,
"showClearButton": true,
}
或者如果您想指定多种语言而不使用默认值:
{
//...
"choices": [
{
"value": "mother",
"text": { "en": "Mother", "de-de": "Mutter" }
},
{
"value": "father",
"text": { "en": "Father", "de-de": "Vater" }
}
],
//..
}