Localize pipeline fallback notifications
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type {Message} from "typescript-telegram-bot-api";
|
||||
import {Localization} from "../../common/localization.js";
|
||||
import {replyToMessage, logError} from "../../util/utils.js";
|
||||
import type {PipelineFallbackDecision} from "./fallback-executor.js";
|
||||
import {PipelineFallbackNotificationRegistry} from "./fallback-notifier-registry.js";
|
||||
@@ -9,6 +10,7 @@ export class PipelineFallbackNotifier {
|
||||
|
||||
constructor(
|
||||
private readonly sourceMessage: Message,
|
||||
private readonly responseLanguage?: string,
|
||||
private readonly sendFallbackMessage: (text: string) => Promise<void> = async text => {
|
||||
await replyToMessage({
|
||||
message: this.sourceMessage,
|
||||
@@ -22,7 +24,10 @@ export class PipelineFallbackNotifier {
|
||||
return {notified: false};
|
||||
}
|
||||
|
||||
const text = resolvePipelineFallbackText(decision.stage, decision.action);
|
||||
const locale = this.responseLanguage === "default"
|
||||
? Localization.currentLocale()
|
||||
: Localization.normalizeLocale(this.responseLanguage) ?? Localization.currentLocale();
|
||||
const text = resolvePipelineFallbackText(decision.stage, decision.action, locale);
|
||||
if (!text) {
|
||||
return {notified: false};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user