angular - How to localize form builder - formio
问题描述
I am implementing a locale for our angular 10 application.
I am using ngx-translate to translate the application content.
We also have user creation forms, where application admins will create a custom form as per their requirements. For this, we are using form.io.
I am using a formio's form-builder which will give the drag and drop components to generate the form,
Whatever components are available those all need to be translated based on application language selection. (Basic, Text Field, Text Area, Display, Data, Validation, etc.) I have gone through the formiojs code and the document Also, I am looking for something exactly like the git issue which already exists, but it does not have enough information which I can start through.
Looking for a guideline that helps me to translate the form-builder components and their properties.
Thank you...
解决方案
I've been through this. Use i18n with formio like this:
var trad_form = JSON.parse(your_json_translation);
Formio.createForm(document.getElementById(id_element),
your_json_form_structure,
{
readOnly: is_read_only,
language: selected_language,
i18n: your_json_trad_form
}).then(function (form) { ... });
And a small part of the json file for the german translation for example would look like this:
var your_json_translation = { "de": { "Number": "Nummer", "Right (Right-aligned)": "Rechts (rechtsbündig)", "Bottom": "Unten", "Placeholder": "Platzhalter", "The placeholder text that will appear when this field is empty.": "Der Platzhaltertext, der angezeigt wird, wenn dieses Feld leer ist.", "Description": "Beschreibung"}};
You have to create that file with all the labels existing in formio.
推荐阅读
- type-conversion - 为什么 Azure 数据流将 varbinary(1000) 转换为 varbinary(max),我该如何防止这种情况发生?
- javascript - JavaScript 中不按按钮的自动代码操作
- c# - Caching Serialized HttpResponseMessage to Redis. Error on read. "InvalidOperationException: The stream was already consumed. It cannot be read again."
- reactjs - Graphql,React - TypeError:无法读取未定义的属性“地图”
- i18next - 如何使用 CLI 使用 i18next 生成输出 json 文件?
- html - Angular page jumps to top when clicking anywhere at the bottom
- python - 将大型多维列表写入CSV中的单个单元格
- python-3.x - 无法连接到面临失败的 PYMQI 客户端:MQRC_ENVIRONMENT_ERROR
- android - Koin 构造函数注入少量参数 MVVM Android 架构
- typescript - 有没有一种合理的方法可以在打字稿中输入“小于 n 的非负整数”?