How to localize form builder
Hi, We are using the angular wrapper for formio (form builder in specific) Formiojs version : 3.21.5
I want to use form builder in other languages. It would help if you can tell the way to add i18n translations for form builder.
Thanks, Vedhachala
http://formio.github.io/formio.js/app/examples/language.html
@randallknutson
I am able to do this for a form where i give the json and the translations for the strings in it. I followed the steps given here and it works.
But i want to do the same to the builder , which is rendered by this code <form-builder [form]="{
components: []
}"></form-builder>
To be specific, examples of strings i want to give my translations are:
'Drag and Drop a form component' . 'Basic Components' (tabs on the left) 'Text Field' . 'Display' (In edit dialog) 'Validation' 'Logic' . 'Custom Default Value' 'Calculated Value'
....etc
basically for all the components under basic, advanced, layout and data also for the input fields (like 'label','Description','Calculated Value','Custom Default Value') in the edit dialog box under display, data, validation, api, conditional, logic tabs for every component.
How to achieve this ?
These are supposed to be able to be translated the same as other values. However, I took a quick look and it appears we are missing the translation wrapper around some of these strings. For example, the "Drag and Drop a form component" is located here: https://github.com/formio/formio.js/blob/master/src/templates/bootstrap/builderPlaceholder/form.ejs
and should be wrapped in {{t('Drag and Drop a form component')}} so that it can be translatable. To fix this, we can either add these wrappers where they are needed or you can override the templates. You can see https://github.com/formio/formio.js/wiki/Form-Templating for how to do this.
The Items like Display, Validation and others like that should already be translatable the same way as Forms.
How about DateTimeComponent (form renderer and viewer)? I was unable to figure out how to translate it. As I understand It wraps flatpickr, and flatpickr itself already has translation of some (not all) of the string constants. I was unable to make it localized through angular API. Some hint would be great!
@randallknutson
I was able to do localization,
But i am seeing few issues , the contents inside all the code inputs (like in custom default value and caluclate value) are not getting changed.

How to translate this section .?
@Vedhachala, that text does not currently support localization, but you can certainly override the function that renders it: https://github.com/formio/formio.js/blob/76ef892261c7c6ca12fc450a34cb94f7ce464029/src/components/_classes/component/editForm/utils.js#L38L61
@aiwebb , I went through the code, to examine how to translate a string using i18n.
I can see that it was just wrapped around a i18next function , for example this.t(this.component.description)
However, I am not able to use that function in utils , at least not by simply importing BaseComponent in the utils.
Can you give any suggestions of ways to use it in editForm utils ?
formiojs version : 3.21.5
@Vedhachala,
Form.io offers Support Packages that are for training, support or development services. The hours can be used in one hour increments at your convenience over a 90 day period. We will assign one of our senior developers to work directly with you in online sessions.
To let us know if you are interested, contact [email protected] and we will send you our Support pricing document.
Thanks.
If anyone is interested in DateTimeComponent localization, this could be done the following way: The standard way of flatpickr localization doesn't work because of the following unresolved issue in flatpickr https://github.com/flatpickr/flatpickr/issues/1429
Workaround: Add the following code to e.g. app.module.ts (change language code from ru to required):
require("node_modules/flatpickr/dist/l10n/ru.js");
(
@Vedhachala I am also looking for the same localization on component properties. Looking forward to detailed information on how did you make it work, what are the changes you made to achieve it?
thank you...
One question, do you know if there is a file with all the string to be translated? I have been searching for it in the code but I haven't seen it
@danielzzz most of the translations for this library use these strings.
https://github.com/formio/formio.js/blob/master/src/translations/en.js
There may be some missing there, and if so, then we welcome a pull request to resolve some of the missing strings.
thanks, @travist ! from what I've seen lot's of strings are being taken dynamically from components. I was looking for a way to dynamically extract them, but didn't found one yet