1. No Translation for ‘No Data’ (NoDataMessage):
The translation for the ‘No Data’ message (NoDataMessage) seems to be missing. When attempting to display a message for an empty data set, the translation is not being applied.
2. Incorrect ID for ‘Required’ Error (error.required):
The translation ID for the ‘Required’ error message (error.required) seems to be incorrect. It appears to be using ‘error.custom’ as the ID instead.
3. Incorrect Input Handling (input):
The translation for ‘input’ does not seem to be handled correctly. When attempting to translate the term ‘input,’ it does not retrieve the appropriate translation.
this is my code:
import { ArrayTranslationEnum, ArrayTranslations, JsonFormsI18nState, Translator } from "@jsonforms/core"
export const translateZhCN: Translator = ( id, defaultMessage, values ) => {
if ( id.includes( "error.required" ) ) {
return '必须填写的字段'
}
const key = id.split( '.' ).pop() // 去掉前缀
const translated = arrayTranslationsZhCN[ key as keyof ArrayTranslations ]
if ( typeof translated === 'function' ) {
return translated( values )
}
console.log( "cant traslate " + id )
return defaultMessage || id
}
export const i18n_ZhCN: JsonFormsI18nState = {
translate: translateZhCN
}
export const arrayTranslationsZhCN = {
[ ArrayTranslationEnum.addTooltip ]: ( input: any ) => ( input ? `添加到 ${ input }` : '添加' ),
[ ArrayTranslationEnum.addAriaLabel ]: ( input: any ) => ( input ? `添加到 ${ input } 按钮` : '添加按钮' ),
[ ArrayTranslationEnum.removeTooltip ]: () => '删除',
[ ArrayTranslationEnum.removeAriaLabel ]: () => '删除按钮',
[ ArrayTranslationEnum.upAriaLabel ]: () => '上移项目',
[ ArrayTranslationEnum.up ]: () => '上移',
[ ArrayTranslationEnum.down ]: () => '下移',
[ ArrayTranslationEnum.downAriaLabel ]: () => '下移项目',
[ ArrayTranslationEnum.noDataMessage ]: () => '空',
[ ArrayTranslationEnum.noSelection ]: () => '无选项',
[ ArrayTranslationEnum.deleteDialogTitle ]: () => '确认删除',
[ ArrayTranslationEnum.deleteDialogMessage ]: () => '确定要删除所选条目吗?',
[ ArrayTranslationEnum.deleteDialogAccept ]: () => '是',
[ ArrayTranslationEnum.deleteDialogDecline ]: () => '否',
}
And I also got a problem in coding,on the Translator last return,I can’t just return defaultMessage. It ask me to return a string.So I change it to defaultMessage || id,which might be wrong.
Seeking guidance, is there something wrong with what I wrote?


