@moebius/fluent
Version:
Better Fluent integration for JavaScript
41 lines • 1.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.LoggingWarningHandler = void 0;
class LoggingWarningHandler {
constructor(options = {}) {
this.options = options;
this.writeLog = ((options === null || options === void 0 ? void 0 : options.logFunction) ||
console.warn);
}
handleWarning(warning) {
switch (warning.type) {
case 'translate.bundle.missing-message': {
const { messageId, bundle } = warning;
this.writeLog(`Translation message (${messageId}) is not found ` +
`for locale(s): ${bundle.locales.join(', ')}`);
break;
}
case 'translate.message.missing-attribute': {
const { attributeName, messageId, bundle } = warning;
this.writeLog(`Missing attribute (${attributeName}) from ` +
`message (${messageId}) for locale(s): ` +
bundle.locales.join(', '));
break;
}
case 'translate.missing-translation': {
const { path, locales } = warning;
this.writeLog(`Translation (${path}) was not found ` +
`for requested locale(s): ${locales.join(', ')}`);
break;
}
default: {
this.writeLog(`Unknown warning raised: ${warning.type}, ` +
`please tell "@moebius/fluent" library author ` +
`to fix this`);
break;
}
}
}
}
exports.LoggingWarningHandler = LoggingWarningHandler;
//# sourceMappingURL=logging-warning-handler.js.map