Localize pipeline fallback notifications

This commit is contained in:
2026-05-18 20:31:04 +03:00
parent 1773b44edd
commit df39d89ea8
9 changed files with 49 additions and 19 deletions
@@ -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};
}