@athome-solution/feedjet 2.1.9 → 2.3.3

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/README.md CHANGED
@@ -109,7 +109,7 @@ new Feedback({
109
109
 
110
110
  ```ts
111
111
  type UserType = { id: string, fullName?: string, profile?: string }
112
- type Locale = 'fr' | 'en' | 'es'
112
+ type Locale = 'fr' | 'en' | 'es' | 'nl'
113
113
 
114
114
  interface FeedbackOptions {
115
115
  target: HTMLElement | { feedback?: HTMLElement } | null | undefined
@@ -126,7 +126,7 @@ interface FeedbackOptions {
126
126
  | `projectId` | Yes | Feedjet project identifier. |
127
127
  | `apiUrl` | Yes | Base URL of the Feedjet API. |
128
128
  | `user` | No | Object or function returning the current user. |
129
- | `locale` | No | `'fr'` \| `'en'` \| `'es'`. Default: `'fr'`. |
129
+ | `locale` | No | A value of [`Locales`](#locales). Default: `Locales.FR`. |
130
130
 
131
131
  ## Feedbot
132
132
 
@@ -168,7 +168,7 @@ document.getElementById('button').addEventListener('click', () => feedbot.increm
168
168
 
169
169
  ```ts
170
170
  type UserType = { id: string, fullName?: string, profile?: string }
171
- type Locale = 'fr' | 'en' | 'es'
171
+ type Locale = 'fr' | 'en' | 'es' | 'nl'
172
172
 
173
173
  interface FeedbotOptions {
174
174
  apiUrl: string
@@ -183,7 +183,26 @@ interface FeedbotOptions {
183
183
  | `apiUrl` | Yes | Base URL of the Feedjet API. |
184
184
  | `surveyId` | Yes | Survey identifier. |
185
185
  | `user` | No | Object or function returning the current user. |
186
- | `locale` | No | `'fr'` \| `'en'` \| `'es'`. Default: `'fr'`. |
186
+ | `locale` | No | A value of [`Locales`](#locales). Default: `Locales.FR`. |
187
+
188
+ ## Locales
189
+
190
+ `Locales` holds the available languages: `Locales.FR`, `Locales.EN`, `Locales.ES` and `Locales.NL`. The raw strings (`'nl'`) are still accepted.
191
+
192
+ ```js
193
+ import { Feedback, Locales } from '@athome-solution/feedjet'
194
+
195
+ new Feedback({
196
+ target: document.getElementById('feedback-widget'),
197
+ projectId: '12345',
198
+ apiUrl: 'https://api.example.com',
199
+ locale: Locales.NL,
200
+ })
201
+ ```
202
+
203
+ With the CDN build, use `Feedjet.Locales.NL`.
204
+
205
+ To add a language, create `src/locales/<code>.ts` typed with `Translations`, then register it in `Locales` and `translations` in `src/i18n.ts`.
187
206
 
188
207
  ## API
189
208
 
package/dist/i18n.d.ts CHANGED
@@ -1,4 +1,10 @@
1
- export type Locale = 'fr' | 'en' | 'es';
1
+ export declare const Locales: {
2
+ readonly FR: "fr";
3
+ readonly EN: "en";
4
+ readonly ES: "es";
5
+ readonly NL: "nl";
6
+ };
7
+ export type Locale = typeof Locales[keyof typeof Locales];
2
8
  export declare function setLocale(locale: Locale): void;
3
9
  export declare function getLocale(): Locale;
4
10
  export declare function t(key: string): string;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { Locale } from './i18n';
2
2
  import { Feedback } from './feedback';
3
3
  import { Feedbot } from './feedbot';
4
- export { Feedback, Feedbot };
4
+ import { Locales } from './i18n';
5
+ export { Feedback, Feedbot, Locales };
5
6
  export type { Locale };