Files
nanobot/webui/src/channel-plugins/i18n.ts
T
chengyongru e8a29a0087 feat(webui): improve setup flows across chat channels (NAN-112) (#5356)
* feat(webui): improve channel setup flows

* fix(webui): refine channel setup interactions (NAN-112)

* fix(webui): keep email setup sections channel-owned

* fix(webui): remove concrete channel details from shared components

* refactor(webui): remove unused channel setup resources

* fix(webui): finish channel-owned setup boundaries

* fix(webui): update channel switches optimistically

* test(channels): remove obsolete absence assertions

* fix(webui): flatten channel instance settings disclosure

* fix(webui): complete channel setup and connection flows

* fix(whatsapp): wait for session database release

* fix(webui): preserve scrolling channel controls

* fix(webui): stage channel connection checks

* fix(channels): align verification actions

* fix(email): expose connection checks

* fix(webui): align channel field actions

* fix(email): verify account credentials

* fix(wecom): bypass system proxy for websocket

* fix(channels): stabilize async connection cleanup

* fix(webui): autosave channel credentials

* fix(email): make provider presets non-destructive

* test(weixin): isolate persisted QR credentials
2026-09-11 15:22:14 +08:00

48 lines
1.2 KiB
TypeScript

import type { TFunction } from "i18next";
type ChannelFieldMessages = {
label: string;
placeholder?: string;
choices?: Record<string, string>;
};
export type ChannelMessages = {
displayName?: string;
setup: {
primaryAction?: string;
docsLabel?: string;
officialLabel?: string;
presetLabel?: string;
sections?: Record<string, string>;
fields?: Record<string, ChannelFieldMessages>;
actions?: Record<string, string>;
presets?: Record<string, string>;
};
custom?: Record<string, string>;
};
export type ChannelTranslator = (
key: string,
fallback: string,
values?: Record<string, unknown>,
) => string;
export function channelNamespace(channel: string): string {
return `channel-${channel}`;
}
export function channelTranslator(t: TFunction, channel: string): ChannelTranslator {
const namespace = channelNamespace(channel);
return (key, fallback, values = {}) => t(key, {
ns: namespace,
defaultValue: fallback,
...values,
});
}
export function channelFieldMessageKey(channel: string, configKey: string): string {
const prefix = `channels.${channel}.`;
const field = configKey.startsWith(prefix) ? configKey.slice(prefix.length) : configKey;
return field.replace(/[^A-Za-z0-9_-]+/g, "_");
}