我需要自定义列表标题,但要在diff中允许它。语言。 我试试:
<List title='Hi there' ...>
并且标题按预期更改但是如何从文件中配置字符串?
<List title={translate('myroot.list.header') ...>
不起作用......
答案 0 :(得分:0)
尝试使用自定义标题组件:
import { translate } from 'admin-on-rest';
const ListTitle = translate(({ translate }) => <span>{translate('my.title')}</span>);
<List title={<ListTitle />} >
答案 1 :(得分:0)
希望它会对你有所帮助:
customMessages.js
export const customMessages = {
titles: {
one: 'First Title',
two: 'Second Title',
},
}
App.js
import { englishMessages } from 'admin-on-rest';
import { customMessages } from './customMessages';
const messages = {
'en': {...englishMessages, ...customMessages},
};
resources.js
export const ResourceList = (props) => (
<List {...props} title="titles.one">
<Datagrid>
<TextField source="id" />
<TextField source="text" />
<EditButton />
<DeleteButton />
</Datagrid>
</List>
);
替换您的姓名:
resources.js
ResourceList