admin-on-rest

Use translation in field components


I have trouble to use the translation in admin on rest. I think i don't really understand how it's work

For example I cannot use translation in this case:

<FunctionField
    label="some.label"
    render={(record, translate) => translate('some.translation')}
/>

I have this error: uncaught at handleFetch TypeError: translate is not a function

Someone would be able to help me on this?


Solution

  • You should return a component on the render function.

    <FunctionField render={
       (record) =>
          <Component label={translate('record.to_translate')} /> 
    } />