Skip to content
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
2 changes: 2 additions & 0 deletions providers/__tests__/i18nProvider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ describe('i18nProvider', () => {
it('translates download and PDF busy errors in Hebrew', () => {
expect(i18nProvider.translate('ra.notification.file_download_incomplete')).toContain('סינון האינטרנט');
expect(i18nProvider.translate('ra.notification.pdf_render_busy')).toBe('המערכת מפיקה כרגע דוחות אחרים. נא לנסות שוב בעוד מספר דקות.');
expect(i18nProvider.translate('ra.notification.pdf_print_timeout')).toContain('הדוח גדול מדי');
});

it('handles missing translations by returning the key', () => {
Expand All @@ -150,6 +151,7 @@ describe('i18nProvider', () => {
it('translates download and PDF busy errors in English', () => {
expect(i18nProvider.translate('ra.notification.file_download_incomplete')).toContain('content filter');
expect(i18nProvider.translate('ra.notification.pdf_render_busy')).toBe('The system is currently generating other reports. Please try again in a few minutes.');
expect(i18nProvider.translate('ra.notification.pdf_print_timeout')).toContain('too large');
});
});
});
Expand Down
2 changes: 2 additions & 0 deletions providers/i18nProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ const extendedTranslation = {
application_update_available: 'גרסה חדשה זמינה.',
file_download_incomplete: 'הקובץ לא התקבל במלואו. ככל הנראה סינון האינטרנט (למשל נטפרי) חסם או קטע את ההורדה. נא לפנות לספק הסינון ולבקש לאשר את האתר, או לנסות להוריד מרשת אחרת.',
pdf_render_busy: 'המערכת מפיקה כרגע דוחות אחרים. נא לנסות שוב בעוד מספר דקות.',
pdf_print_timeout: 'הדוח גדול מדי להפקה כ-PDF. יש לצמצם את הסינון (למשל לטווח תאריכים קצר יותר) או להוריד אותו כקובץ Excel.',
},
validation: {
valueConfirm: 'ערך לא תואם',
Expand Down Expand Up @@ -173,6 +174,7 @@ const extendedEnglishTranslation = {
notification: {
file_download_incomplete: 'The file was not fully received. An internet content filter (such as NetFree) most likely blocked or cut off the download. Please ask your filter provider to approve this site, or try downloading from another network.',
pdf_render_busy: 'The system is currently generating other reports. Please try again in a few minutes.',
pdf_print_timeout: 'The report is too large to produce as a PDF. Narrow the filter (for example, a shorter date range) or download it as an Excel file.',
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions utils/__tests__/httpUtil.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ describe('translateErrorCode', () => {
expect(translateErrorCode(error).message).toBe('ra.notification.pdf_render_busy');
});

it('translates the PDF print timeout code', () => {
const error = buildHttpError({ statusCode: 413, code: 'PDF_PRINT_TIMEOUT', message: 'too big' });
expect(translateErrorCode(error).message).toBe('ra.notification.pdf_print_timeout');
});

it('leaves errors without a known code untouched', () => {
const error = buildHttpError({ statusCode: 500, message: 'Internal server error' });
expect(translateErrorCode(error).message).toBe('Internal server error');
Expand Down
1 change: 1 addition & 0 deletions utils/httpUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { fetchUtils } from 'react-admin';
// translation key, which react-admin's notify() translates to the user's locale.
export const ERROR_CODE_TRANSLATION_KEYS = {
PDF_RENDER_BUSY: 'ra.notification.pdf_render_busy',
PDF_PRINT_TIMEOUT: 'ra.notification.pdf_print_timeout',
};

export const translateErrorCode = (error) => {
Expand Down
Loading