@paramms/chat-widget 1.6.3 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/i18n.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ export type WidgetLocale = 'en' | 'ko';
2
+ /** The auto-localized string set (everything except the two special keys above). */
3
+ export interface WidgetStrings {
4
+ placeholder: string;
5
+ offline: string;
6
+ online: string;
7
+ away: string;
8
+ aiAssistant: string;
9
+ resolved: string;
10
+ reopen: string;
11
+ sources: string;
12
+ helpful: string;
13
+ notHelpful: string;
14
+ title: string;
15
+ newChat: string;
16
+ startChat: string;
17
+ all: string;
18
+ empty: string;
19
+ error: string;
20
+ retry: string;
21
+ search: string;
22
+ unread: string;
23
+ close: string;
24
+ }
25
+ /** Host overrides: any built-in string, plus the two special override-only keys. */
26
+ export type WidgetI18nOverrides = Partial<WidgetStrings> & {
27
+ poweredBy?: string;
28
+ send?: string;
29
+ };
30
+ /** Resolve a supported locale from an explicit option or the browser. KO⇄EN
31
+ * only — anything that isn't Korean resolves to English. Accepts full BCP-47
32
+ * tags ('ko-KR'), bare codes ('ko'), or names ('korean'/'한국어'). */
33
+ export declare function resolveLocale(explicit?: string): WidgetLocale;
34
+ /** The full string set for the resolved locale, with host per-key overrides
35
+ * applied on top (overrides win; blank/undefined override values are ignored so
36
+ * a partial override object never blanks a built-in string). The result may
37
+ * also carry `poweredBy`/`send` when the host provided them. */
38
+ export declare function resolveStrings(locale?: string, overrides?: WidgetI18nOverrides): WidgetStrings & {
39
+ poweredBy?: string;
40
+ send?: string;
41
+ };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { asConversationId } from './protocol/index.js';
2
2
  import { type WidgetConfig } from './renderer.js';
3
+ import { type WidgetI18nOverrides } from './i18n.js';
3
4
  export interface UserInfo {
4
5
  /** Display name shown in the conversation (e.g. "Sarah Chen"). */
5
6
  name?: string;
@@ -65,9 +66,10 @@ export interface MountOptions {
65
66
  /** Inbox scope: 'tenant' (default) lists the user's threads across ALL your
66
67
  * chatrooms; 'profile' limits to this chatroom. */
67
68
  inboxScope?: 'tenant' | 'profile';
68
- /** If set, shows a 🌐 translate button on incoming messages that translates
69
- * them into this language (ISO code or language name) via the server's
70
- * /translate endpoint. Omit to disable the feature. */
69
+ /** Target language for the 🌐 translate button shown under every incoming
70
+ * message (via the server's /translate endpoint). Defaults to the guest's
71
+ * own language (from `locale`/navigator.language) translation is ON by
72
+ * default. Set a specific ISO code to force it, or '' to disable. */
71
73
  translateLang?: string;
72
74
  /** If true, mount as a floating launcher button that opens/closes the chat */
73
75
  launcher?: boolean;
@@ -98,19 +100,13 @@ export interface MountOptions {
98
100
  csat?: boolean;
99
101
  deflection?: boolean;
100
102
  };
101
- /** i18n: override UI strings. All keys are optional omitted keys fall
102
- * back to English defaults. */
103
- i18n?: {
104
- placeholder?: string;
105
- send?: string;
106
- offline?: string;
107
- poweredBy?: string;
108
- online?: string;
109
- away?: string;
110
- aiAssistant?: string;
111
- resolved?: string;
112
- reopen?: string;
113
- };
103
+ /** UI language for built-in strings. A BCP-47 tag ('ko', 'ko-KR'), bare code,
104
+ * or name. Omit to auto-detect from the visitor's browser (navigator.language).
105
+ * Currently Korean ⇄ English; anything non-Korean resolves to English. */
106
+ locale?: string;
107
+ /** i18n: override UI strings. All keys are optional — omitted keys use the
108
+ * built-in dictionary for the resolved `locale` (English by default). */
109
+ i18n?: WidgetI18nOverrides;
114
110
  }
115
111
  export interface WidgetHandle {
116
112
  close(): void;