mirror of
https://github.com/wekan/wekan.git
synced 2026-11-07 11:02:33 -05:00
- Calendar, Calendar Mode and Multi Board Calendar showed archived cards once the Archive sidebar had loaded them; every calendar selector leaves them out now. - Timeline offered "Restore to this state" to every viewer, and a refused restore vanished, since nothing awaited it. The button is shown to those who may change the card, and a refusal is reported. - Table: a swimlane header row spanned a fixed 11 columns, one short with all four date columns and too wide on a phone; it spans the columns the table has. Its add-card error was an English sentence. - Map showed the raw "upload-failed" for a failed upload; it is translated. - client/lib/errorMessage.js turns a failed call into a message in the reader's language: the translation when the error code is a translation key, otherwise the translated "Something went wrong" with the server's reason after it. 25 alert() calls with their own English fallback use it. tests/errorMessageI18n.test.cjs runs the helper and fails on an alert() that falls back to English again; calendarFilter tests the archived cards for all four selectors. Thanks to xet7 !
21 lines
979 B
JavaScript
21 lines
979 B
JavaScript
import { TAPi18n } from '/imports/i18n';
|
|
|
|
// What to tell somebody when a call failed, in their language. A Meteor.Error
|
|
// whose code is a translation key ('error-notAllowed', 'error-board-notAdmin')
|
|
// shows that translation. Anything else shows the translated "Something went
|
|
// wrong", with the server's own reason after it when it gave one: that reason
|
|
// is English, but it is what an admin needs to find the cause.
|
|
//
|
|
// Before this, each alert() fell back to its own English sentence ("Failed to
|
|
// archive board", "Could not add the member.") - 25 of them, untranslated.
|
|
export function errorMessage(error) {
|
|
const code = error && typeof error.error === 'string' ? error.error : '';
|
|
if (code) {
|
|
const translated = TAPi18n.__(code);
|
|
if (translated && translated !== code) return translated;
|
|
}
|
|
const generic = TAPi18n.__('error-undefined');
|
|
const reason = error && (error.reason || error.message);
|
|
return reason ? `${generic} (${reason})` : generic;
|
|
}
|