Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix <Admin> with no i18nProvider logs warnings for missing translations #6032

Merged
merged 1 commit into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/react-admin/src/defaultI18nProvider.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import expect from 'expect';
import defaultI18nProvider from './defaultI18nProvider';

describe('defaultI18nProvider', () => {
it('should use the English translations', () => {
expect(defaultI18nProvider.translate('ra.action.edit')).toBe('Edit');
});
it('should return the input when the translation is missing', () => {
expect(defaultI18nProvider.translate('bar')).toBe('bar');
});
it('should not log any warning for missing translations', () => {
const spy = jest.spyOn(console, 'error');
defaultI18nProvider.translate('foo');
expect(spy).not.toHaveBeenCalled();
spy.mockRestore();
});
});
4 changes: 3 additions & 1 deletion packages/react-admin/src/defaultI18nProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import defaultMessages from 'ra-language-english';
import polyglotI18nProvider from 'ra-i18n-polyglot';

export default polyglotI18nProvider(() => defaultMessages);
export default polyglotI18nProvider(() => defaultMessages, 'en', {
allowMissing: true,
});