I am getting the below example from i18n documentation.
const translator = (key, defaultMessage) => {
console.log(`Key: ${key}, Default Message: ${defaultMessage}`);
return defaultMessage;
};
const [locale, setLocale] = useState<'de'|'en'>('de');
const translation = useMemo(() => translator(locale), [locale]);
<JsonForms
i18n={{locale: locale, translate: translation}}
...
/>
But I am not sure how to pass i18n.json.
schema:
{
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 3,
"description": "Please enter your name",
"i18n": "name"
},
"birthDate": {
"type": "string",
"format": "date",
"i18n": "birth"
},
"nationality": {
"type": "string",
"enum": [
"DE",
"IT",
"JP",
"US",
"RU",
"Other"
],
"i18n": "nationality"
},
"occupation": {
"type": "string",
"i18n": "occupation"
},
"postalCode": {
"type": "string",
"maxLength": 5,
"i18n": "postal-code"
}
},
"required": [
"occupation",
"nationality"
]
}
UI-schema:
{
"type": "VerticalLayout",
"elements": [
{
"type": "HorizontalLayout",
"elements": [
{
"type": "Control",
"scope": "#/properties/name"
},
{
"type": "Control",
"scope": "#/properties/birthDate"
}
]
},
{
"type": "Label",
"text": "Additional Information"
},
{
"type": "HorizontalLayout",
"elements": [
{
"type": "Control",
"scope": "#/properties/nationality"
},
{
"type": "Control",
"scope": "#/properties/postalCode"
}
]
}
]
}
i18n:
{
"en":{
"name":{
"label":"Name",
"description":"The name of the person"
},
"birth":{
"label":"Birth Date",
"description":""
},
"nationality":{
"label":"Nationalitye",
"description":""
},
"postal-code":{
"label":"Postal Codee"
},
"error":{
"required":"field is requirede"
}
},
"de":{
"name":{
"label":"Name",
"description":"Der Name der Person"
},
"birth":{
"label":"Geburtsdatum",
"description":""
},
"nationality":{
"label":"Nationalität",
"description":"",
"Other":"Andere"
},
"postal-code":{
"label":"Postleitzahl"
},
"error":{
"required":"Pflichtfeld"
},
"Additional Information":"Zusätzliche Informationen"
}
}