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