@jotul/jotul-widgets 1.0.2 → 1.0.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/dist/JotulWidget.js +1 -1
- package/dist/i18n/widgetStrings.d.ts +2 -5
- package/dist/i18n/widgetStrings.js +216 -4
- package/dist/utils.js +6 -1
- package/package.json +1 -1
package/dist/JotulWidget.js
CHANGED
|
@@ -20,7 +20,7 @@ const GEOLOCATION_OPTIONS = {
|
|
|
20
20
|
maximumAge: 300000,
|
|
21
21
|
};
|
|
22
22
|
export function JotulWidget({ type, endpoint = '/api/jotul/widget', className, productName, locale: localeProp, market: marketProp, brands, styling, }) {
|
|
23
|
-
const resolvedUiLocale = useMemo(() => resolveWidgetUiLocale(localeProp), [localeProp]);
|
|
23
|
+
const resolvedUiLocale = useMemo(() => resolveWidgetUiLocale(localeProp, marketProp), [localeProp, marketProp]);
|
|
24
24
|
const t = WIDGET_STRINGS[resolvedUiLocale];
|
|
25
25
|
const apiLocaleTag = useMemo(() => (localeProp?.trim() ? localeProp.trim() : DEFAULT_WIDGET_LOCALE_TAG), [localeProp]);
|
|
26
26
|
const apiMarket = useMemo(() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type JotulWidgetLocale = 'no' | 'se' | 'en' | 'fr';
|
|
1
|
+
export type JotulWidgetLocale = 'no' | 'se' | 'en' | 'fr' | 'de' | 'fi' | 'nl' | 'pl' | 'cz';
|
|
2
2
|
/** Default BCP 47 tag used for API `locale` when the prop is omitted. */
|
|
3
3
|
export declare const DEFAULT_WIDGET_LOCALE_TAG = "nb-NO";
|
|
4
4
|
export type WidgetStrings = {
|
|
@@ -38,9 +38,6 @@ export type WidgetStrings = {
|
|
|
38
38
|
readyWarrantyForm: string;
|
|
39
39
|
};
|
|
40
40
|
export declare const WIDGET_STRINGS: Record<JotulWidgetLocale, WidgetStrings>;
|
|
41
|
-
|
|
42
|
-
* Maps `locale` prop: BCP 47 (e.g. `nb-NO`, `en-US`, `fr-FR`) or legacy shorthands (`no`, `sv`).
|
|
43
|
-
*/
|
|
44
|
-
export declare function resolveWidgetUiLocale(raw: string | undefined): JotulWidgetLocale;
|
|
41
|
+
export declare function resolveWidgetUiLocale(raw: string | undefined, market?: string): JotulWidgetLocale;
|
|
45
42
|
/** @deprecated Use `resolveWidgetUiLocale`. */
|
|
46
43
|
export declare const normalizeWidgetLocale: typeof resolveWidgetUiLocale;
|
|
@@ -145,13 +145,217 @@ export const WIDGET_STRINGS = {
|
|
|
145
145
|
readyDealerFinder: 'JotulWidget prêt : dealerFinder',
|
|
146
146
|
readyWarrantyForm: 'JotulWidget prêt : warrantyForm',
|
|
147
147
|
},
|
|
148
|
+
de: {
|
|
149
|
+
genericWidgetError: 'Die Händlersuche ist derzeit nicht verfügbar. Bitte versuchen Sie es später erneut.',
|
|
150
|
+
invalidPostcodeError: 'Geben Sie eine gültige Postleitzahl ein.',
|
|
151
|
+
invalidWidgetTypeError: 'Dieses Widget ist derzeit nicht verfügbar.',
|
|
152
|
+
locationSearchFailed: 'Die Ortssuche konnte nicht abgeschlossen werden. Versuchen Sie es erneut.',
|
|
153
|
+
locationUnavailableBrowser: 'Standort ist in diesem Browser nicht verfügbar. Versuchen Sie einen anderen Browser oder ein anderes Gerät.',
|
|
154
|
+
locationPermissionDenied: 'Der Standortzugriff wurde verweigert. Erlauben Sie den Standortzugriff für diese Seite, um Händler in der Nähe zu finden.',
|
|
155
|
+
locationPositionUnavailable: 'Ihre Position konnte nicht bestimmt werden. Versuchen Sie es gleich noch einmal.',
|
|
156
|
+
locationTimeout: 'Die Standortermittlung hat zu lange gedauert. Versuchen Sie es erneut.',
|
|
157
|
+
locationGenericFailure: 'Ihr Standort konnte nicht gelesen werden. Versuchen Sie es erneut.',
|
|
158
|
+
locationTypeMore: 'Geben Sie mindestens 3 Zeichen ein, um nach einer Adresse zu suchen.',
|
|
159
|
+
locationNoResults: 'Keine Adressen gefunden. Versuchen Sie eine andere Suche.',
|
|
160
|
+
locationManualHint: 'Geben Sie Ihre Adresse ein, um Händler in Ihrer Nähe zu finden.',
|
|
161
|
+
findDealer: 'Händler finden',
|
|
162
|
+
loading: 'Laden …',
|
|
163
|
+
useLocationHint: 'Nutzen Sie Ihren Standort, um Händler in der Nähe zu finden.',
|
|
164
|
+
find: 'Suchen',
|
|
165
|
+
finding: 'Suche …',
|
|
166
|
+
inquirySentSuccess: 'Ihre Anfrage wurde gesendet.',
|
|
167
|
+
goBack: 'Zurück',
|
|
168
|
+
sendInquiryTitle: 'Anfrage',
|
|
169
|
+
sendInquiryTitleWithProduct: 'Anfrage zu {product}',
|
|
170
|
+
dealerWillContact: '{dealer} wird Sie so schnell wie möglich kontaktieren.',
|
|
171
|
+
fieldName: 'Name',
|
|
172
|
+
fieldEmail: 'E-Mail',
|
|
173
|
+
fieldPhone: 'Telefon',
|
|
174
|
+
fieldComment: 'Kommentar',
|
|
175
|
+
formValidationRequired: 'Bitte Name, E-Mail und Telefon eingeben.',
|
|
176
|
+
formValidationEmail: 'Bitte geben Sie eine gültige E-Mail-Adresse ein.',
|
|
177
|
+
dealersNearYou: '{count} Händler in Ihrer Nähe',
|
|
178
|
+
unknownDealer: 'Unbekannter Händler',
|
|
179
|
+
sendInquiryCta: 'Anfrage senden',
|
|
180
|
+
sendInquiryEditing: 'Anfrage bearbeiten',
|
|
181
|
+
readyDealerFinder: 'JotulWidget bereit: dealerFinder',
|
|
182
|
+
readyWarrantyForm: 'JotulWidget bereit: warrantyForm',
|
|
183
|
+
},
|
|
184
|
+
fi: {
|
|
185
|
+
genericWidgetError: 'Jälleenmyyjähaku ei ole juuri nyt käytettävissä. Yritä myöhemmin uudelleen.',
|
|
186
|
+
invalidPostcodeError: 'Anna kelvollinen postinumero.',
|
|
187
|
+
invalidWidgetTypeError: 'Tämä widget ei ole tällä hetkellä käytettävissä.',
|
|
188
|
+
locationSearchFailed: 'Sijainnin haku ei onnistunut. Yritä uudelleen.',
|
|
189
|
+
locationUnavailableBrowser: 'Sijainti ei ole saatavilla tässä selaimessa. Kokeile toista selainta tai laitetta.',
|
|
190
|
+
locationPermissionDenied: 'Sijainnin käyttö estettiin. Salli sijainti tälle sivustolle löytääksesi lähimmät jälleenmyyjät.',
|
|
191
|
+
locationPositionUnavailable: 'Sijaintiasi ei voitu määrittää. Yritä hetken kuluttua uudelleen.',
|
|
192
|
+
locationTimeout: 'Sijainnin haku kesti liian kauan. Yritä uudelleen.',
|
|
193
|
+
locationGenericFailure: 'Sijaintiasi ei voitu lukea. Yritä uudelleen.',
|
|
194
|
+
locationTypeMore: 'Kirjoita vähintään 3 merkkiä hakeaksesi osoitetta.',
|
|
195
|
+
locationNoResults: 'Osoitteita ei löytynyt. Kokeile toista hakua.',
|
|
196
|
+
locationManualHint: 'Anna osoitteesi löytääksesi lähimmät jälleenmyyjät.',
|
|
197
|
+
findDealer: 'Etsi jälleenmyyjä',
|
|
198
|
+
loading: 'Ladataan …',
|
|
199
|
+
useLocationHint: 'Käytä sijaintiasi löytääksesi lähimmät jälleenmyyjät.',
|
|
200
|
+
find: 'Etsi',
|
|
201
|
+
finding: 'Haetaan …',
|
|
202
|
+
inquirySentSuccess: 'Pyyntösi on lähetetty.',
|
|
203
|
+
goBack: 'Takaisin',
|
|
204
|
+
sendInquiryTitle: 'Pyyntö',
|
|
205
|
+
sendInquiryTitleWithProduct: 'Pyyntö tuotteesta {product}',
|
|
206
|
+
dealerWillContact: '{dealer} ottaa sinuun yhteyttä mahdollisimman pian.',
|
|
207
|
+
fieldName: 'Nimi',
|
|
208
|
+
fieldEmail: 'Sähköposti',
|
|
209
|
+
fieldPhone: 'Puhelin',
|
|
210
|
+
fieldComment: 'Kommentti',
|
|
211
|
+
formValidationRequired: 'Täytä nimi, sähköposti ja puhelin.',
|
|
212
|
+
formValidationEmail: 'Anna kelvollinen sähköpostiosoite.',
|
|
213
|
+
dealersNearYou: '{count} jälleenmyyjää lähelläsi',
|
|
214
|
+
unknownDealer: 'Tuntematon jälleenmyyjä',
|
|
215
|
+
sendInquiryCta: 'Lähetä pyyntö',
|
|
216
|
+
sendInquiryEditing: 'Muokataan pyyntöä',
|
|
217
|
+
readyDealerFinder: 'JotulWidget valmis: dealerFinder',
|
|
218
|
+
readyWarrantyForm: 'JotulWidget valmis: warrantyForm',
|
|
219
|
+
},
|
|
220
|
+
nl: {
|
|
221
|
+
genericWidgetError: 'De dealerzoeker is momenteel niet beschikbaar. Probeer het later opnieuw.',
|
|
222
|
+
invalidPostcodeError: 'Voer een geldige postcode in.',
|
|
223
|
+
invalidWidgetTypeError: 'Deze widget is momenteel niet beschikbaar.',
|
|
224
|
+
locationSearchFailed: 'Locatie zoeken kon niet worden voltooid. Probeer opnieuw.',
|
|
225
|
+
locationUnavailableBrowser: 'Locatie is niet beschikbaar in deze browser. Probeer een andere browser of apparaat.',
|
|
226
|
+
locationPermissionDenied: 'Locatietoegang is geweigerd. Sta locatie toe voor deze site om dealers in de buurt te vinden.',
|
|
227
|
+
locationPositionUnavailable: 'Uw locatie kon niet worden bepaald. Probeer het zo opnieuw.',
|
|
228
|
+
locationTimeout: 'Het bepalen van uw locatie duurde te lang. Probeer opnieuw.',
|
|
229
|
+
locationGenericFailure: 'Kon uw locatie niet lezen. Probeer opnieuw.',
|
|
230
|
+
locationTypeMore: 'Typ minimaal 3 tekens om een adres te zoeken.',
|
|
231
|
+
locationNoResults: 'Geen adressen gevonden. Probeer een andere zoekopdracht.',
|
|
232
|
+
locationManualHint: 'Voer uw adres in om dealers in de buurt te vinden',
|
|
233
|
+
findDealer: 'Dealer zoeken',
|
|
234
|
+
loading: 'Laden …',
|
|
235
|
+
useLocationHint: 'Gebruik uw locatie om dealers in de buurt te vinden',
|
|
236
|
+
find: 'Zoeken',
|
|
237
|
+
finding: 'Zoeken …',
|
|
238
|
+
inquirySentSuccess: 'Uw aanvraag is verzonden.',
|
|
239
|
+
goBack: 'Terug',
|
|
240
|
+
sendInquiryTitle: 'Aanvraag',
|
|
241
|
+
sendInquiryTitleWithProduct: 'Aanvraag over {product}',
|
|
242
|
+
dealerWillContact: '{dealer} neemt zo snel mogelijk contact met u op.',
|
|
243
|
+
fieldName: 'Naam',
|
|
244
|
+
fieldEmail: 'E-mail',
|
|
245
|
+
fieldPhone: 'Telefoon',
|
|
246
|
+
fieldComment: 'Opmerking',
|
|
247
|
+
formValidationRequired: 'Vul naam, e-mail en telefoon in.',
|
|
248
|
+
formValidationEmail: 'Voer een geldig e-mailadres in.',
|
|
249
|
+
dealersNearYou: '{count} dealers in de buurt',
|
|
250
|
+
unknownDealer: 'Onbekende dealer',
|
|
251
|
+
sendInquiryCta: 'Aanvraag verzenden',
|
|
252
|
+
sendInquiryEditing: 'Aanvraag bewerken',
|
|
253
|
+
readyDealerFinder: 'JotulWidget klaar: dealerFinder',
|
|
254
|
+
readyWarrantyForm: 'JotulWidget klaar: warrantyForm',
|
|
255
|
+
},
|
|
256
|
+
pl: {
|
|
257
|
+
genericWidgetError: 'Wyszukiwarka dealerów jest obecnie niedostępna. Spróbuj ponownie później.',
|
|
258
|
+
invalidPostcodeError: 'Wpisz prawidłowy kod pocztowy.',
|
|
259
|
+
invalidWidgetTypeError: 'Ten widget jest obecnie niedostępny.',
|
|
260
|
+
locationSearchFailed: 'Nie udało się zakończyć wyszukiwania lokalizacji. Spróbuj ponownie.',
|
|
261
|
+
locationUnavailableBrowser: 'Lokalizacja nie jest dostępna w tej przeglądarce. Spróbuj innej przeglądarki lub urządzenia.',
|
|
262
|
+
locationPermissionDenied: 'Odmówiono dostępu do lokalizacji. Zezwól na lokalizację dla tej strony, aby znaleźć dealerów w pobliżu.',
|
|
263
|
+
locationPositionUnavailable: 'Nie udało się określić Twojej lokalizacji. Spróbuj ponownie za chwilę.',
|
|
264
|
+
locationTimeout: 'Wyszukiwanie Twojej lokalizacji trwało zbyt długo. Spróbuj ponownie.',
|
|
265
|
+
locationGenericFailure: 'Nie udało się odczytać Twojej lokalizacji. Spróbuj ponownie.',
|
|
266
|
+
locationTypeMore: 'Wpisz co najmniej 3 znaki, aby wyszukać adres.',
|
|
267
|
+
locationNoResults: 'Nie znaleziono adresów. Spróbuj innego wyszukiwania.',
|
|
268
|
+
locationManualHint: 'Wpisz swój adres, aby znaleźć dealerów w pobliżu',
|
|
269
|
+
findDealer: 'Znajdź dealera',
|
|
270
|
+
loading: 'Ładowanie …',
|
|
271
|
+
useLocationHint: 'Użyj swojej lokalizacji, aby znaleźć dealerów w pobliżu',
|
|
272
|
+
find: 'Szukaj',
|
|
273
|
+
finding: 'Wyszukiwanie …',
|
|
274
|
+
inquirySentSuccess: 'Twoje zapytanie zostało wysłane.',
|
|
275
|
+
goBack: 'Wstecz',
|
|
276
|
+
sendInquiryTitle: 'Zapytanie',
|
|
277
|
+
sendInquiryTitleWithProduct: 'Zapytanie dotyczące {product}',
|
|
278
|
+
dealerWillContact: '{dealer} skontaktuje się z Tobą tak szybko, jak to możliwe.',
|
|
279
|
+
fieldName: 'Imię i nazwisko',
|
|
280
|
+
fieldEmail: 'E-mail',
|
|
281
|
+
fieldPhone: 'Telefon',
|
|
282
|
+
fieldComment: 'Komentarz',
|
|
283
|
+
formValidationRequired: 'Wpisz imię, e-mail i telefon.',
|
|
284
|
+
formValidationEmail: 'Wpisz prawidłowy adres e-mail.',
|
|
285
|
+
dealersNearYou: '{count} dealerów w pobliżu',
|
|
286
|
+
unknownDealer: 'Nieznany dealer',
|
|
287
|
+
sendInquiryCta: 'Wyślij zapytanie',
|
|
288
|
+
sendInquiryEditing: 'Edycja zapytania',
|
|
289
|
+
readyDealerFinder: 'JotulWidget gotowy: dealerFinder',
|
|
290
|
+
readyWarrantyForm: 'JotulWidget gotowy: warrantyForm',
|
|
291
|
+
},
|
|
292
|
+
cz: {
|
|
293
|
+
genericWidgetError: 'Vyhledávač prodejců je momentálně nedostupný. Zkuste to prosím později.',
|
|
294
|
+
invalidPostcodeError: 'Zadejte platné PSČ.',
|
|
295
|
+
invalidWidgetTypeError: 'Tento widget není momentálně dostupný.',
|
|
296
|
+
locationSearchFailed: 'Vyhledání polohy se nepodařilo dokončit. Zkuste to znovu.',
|
|
297
|
+
locationUnavailableBrowser: 'Poloha není v tomto prohlížeči dostupná. Zkuste jiný prohlížeč nebo zařízení.',
|
|
298
|
+
locationPermissionDenied: 'Přístup k poloze byl zamítnut. Povolte polohu pro tento web, abyste našli prodejce v okolí.',
|
|
299
|
+
locationPositionUnavailable: 'Vaši polohu se nepodařilo zjistit. Zkuste to za chvíli znovu.',
|
|
300
|
+
locationTimeout: 'Vyhledání vaší polohy trvalo příliš dlouho. Zkuste to znovu.',
|
|
301
|
+
locationGenericFailure: 'Nepodařilo se načíst vaši polohu. Zkuste to znovu.',
|
|
302
|
+
locationTypeMore: 'Zadejte alespoň 3 znaky pro hledání adresy.',
|
|
303
|
+
locationNoResults: 'Nebyly nalezeny žádné adresy. Zkuste jiné hledání.',
|
|
304
|
+
locationManualHint: 'Zadejte svou adresu a najděte prodejce ve svém okolí',
|
|
305
|
+
findDealer: 'Najít prodejce',
|
|
306
|
+
loading: 'Načítání …',
|
|
307
|
+
useLocationHint: 'Použijte svou polohu pro nalezení prodejců v okolí',
|
|
308
|
+
find: 'Najít',
|
|
309
|
+
finding: 'Vyhledávání …',
|
|
310
|
+
inquirySentSuccess: 'Váš požadavek byl odeslán.',
|
|
311
|
+
goBack: 'Zpět',
|
|
312
|
+
sendInquiryTitle: 'Poptávka',
|
|
313
|
+
sendInquiryTitleWithProduct: 'Poptávka na {product}',
|
|
314
|
+
dealerWillContact: '{dealer} vás bude co nejdříve kontaktovat.',
|
|
315
|
+
fieldName: 'Jméno',
|
|
316
|
+
fieldEmail: 'E-mail',
|
|
317
|
+
fieldPhone: 'Telefon',
|
|
318
|
+
fieldComment: 'Komentář',
|
|
319
|
+
formValidationRequired: 'Vyplňte jméno, e-mail a telefon.',
|
|
320
|
+
formValidationEmail: 'Zadejte platnou e-mailovou adresu.',
|
|
321
|
+
dealersNearYou: '{count} prodejců v okolí',
|
|
322
|
+
unknownDealer: 'Neznámý prodejce',
|
|
323
|
+
sendInquiryCta: 'Odeslat poptávku',
|
|
324
|
+
sendInquiryEditing: 'Úprava poptávky',
|
|
325
|
+
readyDealerFinder: 'JotulWidget připraven: dealerFinder',
|
|
326
|
+
readyWarrantyForm: 'JotulWidget připraven: warrantyForm',
|
|
327
|
+
},
|
|
148
328
|
};
|
|
149
329
|
/**
|
|
150
330
|
* Maps `locale` prop: BCP 47 (e.g. `nb-NO`, `en-US`, `fr-FR`) or legacy shorthands (`no`, `sv`).
|
|
151
331
|
*/
|
|
152
|
-
|
|
153
|
-
|
|
332
|
+
function localeFromMarket(rawMarket) {
|
|
333
|
+
const m = rawMarket?.trim().toUpperCase();
|
|
334
|
+
if (!m)
|
|
335
|
+
return null;
|
|
336
|
+
if (m === 'NO')
|
|
154
337
|
return 'no';
|
|
338
|
+
if (m === 'SE')
|
|
339
|
+
return 'se';
|
|
340
|
+
if (m === 'FR')
|
|
341
|
+
return 'fr';
|
|
342
|
+
if (m === 'DE')
|
|
343
|
+
return 'de';
|
|
344
|
+
if (m === 'FI')
|
|
345
|
+
return 'fi';
|
|
346
|
+
if (m === 'NL')
|
|
347
|
+
return 'nl';
|
|
348
|
+
if (m === 'PL')
|
|
349
|
+
return 'pl';
|
|
350
|
+
if (m === 'CZ')
|
|
351
|
+
return 'cz';
|
|
352
|
+
if (m === 'GB' || m === 'EN' || m === 'US' || m === 'AU' || m === 'CA')
|
|
353
|
+
return 'en';
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
export function resolveWidgetUiLocale(raw, market) {
|
|
357
|
+
if (raw == null || raw.trim() === '') {
|
|
358
|
+
return localeFromMarket(market) ?? 'no';
|
|
155
359
|
}
|
|
156
360
|
const s = raw.trim();
|
|
157
361
|
const lower = s.toLowerCase();
|
|
@@ -173,11 +377,19 @@ export function resolveWidgetUiLocale(raw) {
|
|
|
173
377
|
if (lang === 'fr')
|
|
174
378
|
return 'fr';
|
|
175
379
|
if (lang === 'de')
|
|
176
|
-
return '
|
|
380
|
+
return 'de';
|
|
381
|
+
if (lang === 'fi')
|
|
382
|
+
return 'fi';
|
|
383
|
+
if (lang === 'nl')
|
|
384
|
+
return 'nl';
|
|
385
|
+
if (lang === 'pl')
|
|
386
|
+
return 'pl';
|
|
387
|
+
if (lang === 'cs')
|
|
388
|
+
return 'cz';
|
|
177
389
|
return 'no';
|
|
178
390
|
}
|
|
179
391
|
catch {
|
|
180
|
-
return 'no';
|
|
392
|
+
return localeFromMarket(market) ?? 'no';
|
|
181
393
|
}
|
|
182
394
|
}
|
|
183
395
|
/** @deprecated Use `resolveWidgetUiLocale`. */
|
package/dist/utils.js
CHANGED
|
@@ -32,7 +32,12 @@ export function getDealerName(dealer, unknownLabel) {
|
|
|
32
32
|
export function getDealerAddressLines(dealer) {
|
|
33
33
|
const address = asText(dealer.address);
|
|
34
34
|
const postalCode = asText(dealer.postalCode);
|
|
35
|
-
|
|
35
|
+
const city = asText(dealer.city);
|
|
36
|
+
const county = asText(dealer.county);
|
|
37
|
+
const locationLine = [postalCode, city, county]
|
|
38
|
+
.filter((value) => !!value)
|
|
39
|
+
.join(', ');
|
|
40
|
+
return [address, locationLine || null].filter((value) => Boolean(value));
|
|
36
41
|
}
|
|
37
42
|
export function createInquiryFormValues(productName, dealerName) {
|
|
38
43
|
return {
|