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

Allow resource specific translations for pages and buttons

Open djhi opened this issue 8 months ago • 2 comments

Problem

We have many translations that receive (or should receive) the current resource, for instance:

  • ra.page.create (and other similar views)
  • ra.action.create (and other similar actions)

However, in some languages such as French, some words are feminine and other masculine. This forces devs to have their own translations if they want:

  • New board : Nouveau tableau
  • New column : Nouvelle colonne

Solution

Just like we did for notifications, accept resource specific translations in the form:

  • resources.posts.page.create
  • resources.posts.action.create

Those translations should fall back to the current translations.

I identified the following translations but there may be others:

  • create default title
  • edit default title
  • show default title
  • list and infinite list default title
  • create button label

How To Test

  • https://react-admin-storybook-moe9v68sh-marmelab.vercel.app/?path=/story/ra-core-controller-createbase--default-title
  • https://react-admin-storybook-moe9v68sh-marmelab.vercel.app/?path=/story/ra-core-controller-editbase--default-title
  • https://react-admin-storybook-moe9v68sh-marmelab.vercel.app/?path=/story/ra-core-controller-showbase--default-title
  • https://react-admin-storybook-moe9v68sh-marmelab.vercel.app/?path=/story/ra-core-controller-list-infinitelistbase--default-title
  • https://react-admin-storybook-moe9v68sh-marmelab.vercel.app/?path=/story/ra-core-controller-list-listbase--default-title
  • https://react-admin-storybook-moe9v68sh-marmelab.vercel.app/?path=/story/ra-ui-materialui-button-createbutton--label

Additional Checks

  • [x] The PR targets master for a bugfix or a documentation fix, or next for a feature
  • [x] The PR includes unit tests (if not possible, describe why)
  • [x] The PR includes one or several stories (if not possible, describe why)
  • [x] The documentation is up to date

Also, please make sure to read the contributing guidelines.

djhi avatar Apr 21 '25 12:04 djhi

I'm a bit worried by the fact that the resource-specific translation keys for the CreateButton and the Create pages are the same. In my opinion, users should be able to have different translations for those (e.g. "Create" for the button and "New post" for the page).

fzaninotto avatar Apr 24 '25 08:04 fzaninotto

I'm a bit worried by the fact that the resource-specific translation keys for the CreateButton and the Create pages are the same. In my opinion, users should be able to have different translations for those (e.g. "Create" for the button and "New post" for the page).

They're not the same. One is page.create, the other action.create

djhi avatar Apr 24 '25 09:04 djhi