Repository navigation
Fix inspector editors ignoring the ra.configurable translations - #11468
Open
farisbasha wants to merge 2 commits into
Open
farisbasha wants to merge 2 commits into
farisbasha wants to merge 2 commits into
Conversation
The Datagrid, SimpleForm and SimpleList editors set their inspector title with ra.inspector.*.title keys, and FieldsSelector translated its buttons with ra.inspector.hideAll / ra.inspector.showAll. None of these keys exist in the translation messages: they are defined under ra.configurable.* in TranslationMessages and in every language package. The English fallback hid the problem, but non-English apps showed the English text.
ThieryMichel
requested changes
Nov 25, 2026
Comment on lines
+48
to
+75
| describe('i18n', () => { | ||
| it('should translate the inspector title and buttons with the ra.configurable messages', async () => { | ||
| const messages: Record<string, string> = { | ||
| 'ra.configurable.SimpleForm.title': 'Translated form', | ||
| 'ra.configurable.inspector.hideAll': 'Translated hide all', | ||
| 'ra.configurable.inspector.showAll': 'Translated show all', | ||
| }; | ||
| const i18nProvider: I18nProvider = { | ||
| translate: (key, options) => messages[key] ?? options?._ ?? key, | ||
| changeLocale: () => Promise.resolve(), | ||
| getLocale: () => 'en', | ||
| }; | ||
| render( | ||
| <I18nContextProvider value={i18nProvider}> | ||
| <Basic /> | ||
| </I18nContextProvider> | ||
| ); | ||
| screen.getByLabelText('Configure mode').click(); | ||
| await screen.findByText('Inspector'); | ||
| fireEvent.mouseOver( | ||
| screen.getAllByDisplayValue('War and Peace')[0] | ||
| ); | ||
| await screen.getByTitle('ra.configurable.customize').click(); | ||
| await screen.findByText('Translated form'); | ||
| expect(screen.queryByText('Translated hide all')).not.toBeNull(); | ||
| expect(screen.queryByText('Translated show all')).not.toBeNull(); | ||
| }); | ||
| }); |
Contributor
There was a problem hiding this comment.
Can you reuse stories in SimpleFormConfigurable.stories.tsx:97. You just have to add fr language to that story to be able to create a realistic test.
Contributor
Author
There was a problem hiding this comment.
Done in 4034bc2: the I18N story now has French and a locale prop, and the test renders <I18N locale="fr" /> and checks the French inspector title and Hide all / Show all buttons.
Add French to the SimpleFormConfigurable I18N story (with a locale prop) and test the inspector against it, as suggested in review.
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The inspector editors use translation keys that do not exist:
DatagridEditor,SimpleFormEditorandSimpleListEditorcalluseSetInspectorTitle('ra.inspector.Datagrid.title' | 'ra.inspector.SimpleForm.title' | 'ra.inspector.SimpleList.title', ...)FieldsSelectortranslates its buttons withra.inspector.hideAllandra.inspector.showAllThese messages are defined under
ra.configurable.*(ra.configurable.Datagrid.title,ra.configurable.SimpleForm.title,ra.configurable.SimpleList.title,ra.configurable.inspector.hideAll,ra.configurable.inspector.showAll) inTranslationMessages,ra-language-englishandra-language-french. Nora.inspectorsection exists in any of them.In English the
_fallback text matches, so nothing looks wrong. With any other language, the inspector title and the "Hide All" / "Show All" buttons stay in English. For example, withra-language-frenchthey show "Datagrid" and "Hide All" instead of "Tableau" and "Masquer tout".Solution
Use the existing
ra.configurable.*keys. The English fallbacks (_) are unchanged, so English apps render the same text as before.How To Test
Added a unit test in
SimpleFormConfigurable.spec.tsx. It renders theBasicstory with an i18nProvider that only knows thera.configurable.*messages, opens the SimpleForm editor, and checks that the translated title and Hide/Show All labels are shown. Without the fix, the editor asks for thera.inspector.*keys, so this provider returns the English fallback and the test cannot find the translated text.Manual check: use
polyglotI18nProviderwithra-language-french, enable the configure mode on a<DatagridConfigurable>, and open the column editor. The inspector should show "Tableau" with "Masquer tout" / "Afficher tout".Additional Checks
masterfor a bugfix or a documentation fix, ornextfor a featureSimpleFormConfigurable/DatagridConfigurablestories already show these editorsI prepared this with an AI assistant. I verified it by reading the code, comparing the keys with
TranslationMessagesand the language packages, and syntax-checking the changed files. I did not run the test suite locally, so CI will be the test run.