【问题标题】:translate field values based on array of translations根据翻译数组翻译字段值
【发布时间】:2020-12-11 19:48:14
【问题描述】:

我有一个 javascript/jquery 脚本,我想根据隐藏字段值(语言)更改表单字段值。

即。隐藏字段

<input type=text id="language" hidden value="nl">

表单域

<select name="Campus" id="Campus" class="form-control input-lg">
   <option value="">Select Campus</option>
</select>
<select name="Bootcamp" id="Bootcamp" class="form-control input-lg">
   <option value="">Select Bootcamp</option>
</select>
English: Select Campus
Spanish: Quiero asistir a este campus
French: Je veux rejoindre ce campus
Portuguese: Quero frequentar este campus
German: Ich möchte an diesem Campus teilnehmen
Dutch: Ik wil deze campus bezoeken

Bootcamp field
English: Select bootcamp
Spanish: Estoy interesado en este bootcamp
French: Je suis intéressé.e par ce cours
Portuguese: Tenho interesse neste bootcamp
German: Ich interessiere mich für dieses Bootcamp
Dutch: Ik ben geïnteresseerd in deze bootcamp

所以基本上,我需要根据隐藏字段值将文本 “Select Bootcamp”“Select Campus” 翻译成所需的语言。因此,在上面的示例中 'NL' - 荷兰语,我希望将字段翻译为 “Ik wil deze Campus bezoeken”“Ik ben geïnteresseerd in deze bootcamp "

我想我需要某种多维数组,jquery 可以使用它来更改文档准备好了吗?

类似的东西?

const languageArray  = [{ code: 'nl', campus: 'Ik wil deze campus bezoeken', bootcamp: 'Ik ben geïnteresseerd in deze bootcamp' }, { code: 'en', campus: 'Select Campus', bootcamp: 'Select Bootcamp' }]

问候, 克雷格。

【问题讨论】:

    标签: javascript jquery arrays translation


    【解决方案1】:

    我想通了..我已经完成了数组的一半:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-02-14
      • 1970-01-01
      • 2015-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多