Formio-multiple-form-translate
HTML
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://unpkg.com/formiojs@4.11.0/dist/formio.full.min.css">
<script src="https://unpkg.com/formiojs@4.11.0/dist/formio.full.min.js"></script>
</head>
<body>
<div id="formio1"></div>
<br><br>
<div id="formio2"></div>
</body>
</html>
JavaScript
let json1 = {
"components": [{
"label": "Text Field",
"tableView": true,
"key": "textField",
"type": "textfield",
"input": true
},
{
"type": "button",
"label": "Submit",
"key": "submit",
"disableOnInvalid": true,
"input": true,
"tableView": false
}
]
};
let json2 = {
"components": [{
"label": "Name",
"tableView": true,
"key": "name",
"type": "textfield",
"input": true
},
{
"type": "button",
"label": "Apply",
"key": "apply",
"disableOnInvalid": true,
"input": true,
"tableView": false
}
]
};
window.onload = function() {
Formio.icons = 'fontawesome';
Formio.createForm(document.getElementById('formio1'), json1, {
language: "fr",
i18n: {
resources: {
fr: {
translation: {
"Submit": "fr submit (1)",
"Text Field": "fr text (1)",
"Name": "fr name (1)",
"Apply": "fr apply (1)"
}
}
}
}
})
.then(function(form) {
const i18next = form.i18next.createInstance()
Formio.createForm(document.getElementById('formio2'), json2, {
language: "fr",
i18next,
i18n: {
resources: {
fr: {
translation: {
"Name": "fr name (2)",
"Apply": "fr apply (2)"
}
}
}
}
});
});
};