react
react copied to clipboard
Am trying to achieve language support . when am changing the language switch its not working
let options = { language: 'en', i18n: { ar: { 'First Name': 'الاسم الاول', 'Last Name': 'الكنية', 'Enter your first name': 'أدخل اسمك الأول', 'Enter your last name': 'أدخل اسمك الأخير', 'How would you rate the Form.io platform?': '¿Cómo calificaría la plataforma Form.io?', 'How was Customer Support?': '¿Cómo fue el servicio de atención al cliente?', 'Overall Experience?': '¿Experiencia general?', Survey: 'Encuesta', Excellent: 'Excelente', Great: 'Estupendo', Good: 'Bueno', Average: 'Promedio', Poor: 'Pobre', 'Submit': 'إرسال' }, ch: { 'First Name': '名字', 'Last Name': '姓', 'Enter your first name': '输入你的名字', 'Enter your last name': '输入你的姓氏', 'How would you rate the Form.io platform?': '你如何评价Form.io平台?', 'How was Customer Support?': '客户支持如何?', 'Overall Experience?': '总体体验?', Survey: '调查', Excellent: '优秀', Great: '大', Good: '好', Average: '平均', Poor: '错', 'Submit': '提交' } } }
When i set to options.language= "ar" Form io is not rendering with language changes to "ar" If i set to language="ar" by default it was working
@vishaldenzil
Have you taken a look at this documentation:https://help.form.io/tutorials/walkthroughs/translations/ as well as this example:https://formio.github.io/formio.js/app/examples/language.html
Thank you.
Yes . I saw that examples . In react Form.js this.componentWillReceiveProps = function (nextProps) { var _props2 = _this2.props, _props2$options = _props2.options, options = _props2$options === undefined ? {} : _props2$options, src = _props2.src, form = _props2.form, submission = _props2.submission;
if (!options.events) {
options.events = Form.getDefaultEmitter();
}
if (src !== nextProps.src) {
_this2.createPromise = new (_this2.props.formioform || _Form2.default)(_this2.element, nextProps.src, options).render().then(function (formio) {
_this2.formio = formio;
_this2.formio.src = nextProps.src;
});
_this2.initializeFormio();
}
if (form !== nextProps.form) {
_this2.createPromise = new (_this2.props.formioform || _Form2.default)(_this2.element, nextProps.form, options).render().then(function (formio) {
_this2.formio = formio;
_this2.formio.form = nextProps.form;
});
_this2.initializeFormio();
}
if (submission !== nextProps.submission && _this2.formio) {
_this2.formio.submission = nextProps.submission;
}
if(nextProps.options.language) {
_this2.createPromise = new (_this2.props.formioform || _Form2.default)(_this2.element, nextProps.form, nextProps.options).render().then(function (formio) {
_this2.formio = formio;
_this2.formio.options = nextProps.options
})
_this2.initializeFormio();
}
}; After changing like this its working fine . When i was setting language . Options has not re rendered again
if(nextProps.options.language) { _this2.createPromise = new (_this2.props.formioform || _Form2.default)(_this2.element, nextProps.form, nextProps.options).render().then(function (formio) { _this2.formio = formio; _this2.formio.options = nextProps.options }) _this2.initializeFormio(); }
Is there a solution for this problem. I am facing the same issue. Thanks!
@vishaldenzil
I am closing the issue as it was created too long ago and there are no new comments here. I hope it was resolved. If not, please reopen it. Thanks!