react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

Automatic translation (i18n) support for emptyText

Open soullivaneuh opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

The emptyText prop value of field components is not automatically translated as it is done for the label prop.

Describe the solution you'd like

Having the possibility to have the emptyText prop value being translated when available for example:

<Tab
  // The label prop is being automatically translated.
  label="resources.rides.tabs.path"
  path="path"
>
  <DateField
    source="startedAt"
    showTime
    // Expected to be translated too.
    emptyText="resources.rides.emptyText.notStarted"
  />
</Tab>

Describe alternatives you've considered

I am using useTranslate hooks with the result store in a variable like so: const t = useTranslate();

Then I translate the key manually:

  <DateField
    source="startedAt"
    showTime
    emptyText={t('resources.rides.emptyText.notStarted')}
  />

Additional context

N/A

soullivaneuh avatar Aug 07 '22 15:08 soullivaneuh

That's a nice idea. We would gladly welcome a PR on this topic! The PR should include the code, unit tests, and the documentation.

antoinefricker avatar Aug 08 '22 08:08 antoinefricker

@fzaninotto @septentrion-730n the adjustment here must be for all fields or just for the date? I can raise this PR!

ogustavo-pereira avatar Aug 29 '22 23:08 ogustavo-pereira

Please do it for all fields.

fzaninotto avatar Aug 30 '22 16:08 fzaninotto

Should this issue be closed now? cc @fzaninotto @septentrion-730n

ogustavo-pereira avatar Sep 08 '22 15:09 ogustavo-pereira

Indeed, thanks!

fzaninotto avatar Sep 08 '22 15:09 fzaninotto