@schukai/monster 4.38.9 → 4.38.10
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/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/source/components/accessibility/locale-picker.mjs +541 -541
- package/source/i18n/util.mjs +142 -142
@@ -13,17 +13,17 @@
|
|
13
13
|
import { instanceSymbol } from "../../constants.mjs";
|
14
14
|
import { addAttributeToken } from "../../dom/attributes.mjs";
|
15
15
|
import {
|
16
|
-
|
17
|
-
|
16
|
+
ATTRIBUTE_ERRORMESSAGE,
|
17
|
+
ATTRIBUTE_ROLE,
|
18
18
|
} from "../../dom/constants.mjs";
|
19
19
|
import { CustomControl } from "../../dom/customcontrol.mjs";
|
20
20
|
import {
|
21
|
-
|
22
|
-
|
21
|
+
CustomElement,
|
22
|
+
updaterTransformerMethodsSymbol,
|
23
23
|
} from "../../dom/customelement.mjs";
|
24
24
|
import {
|
25
|
-
|
26
|
-
|
25
|
+
assembleMethodSymbol,
|
26
|
+
registerCustomElement,
|
27
27
|
} from "../../dom/customelement.mjs";
|
28
28
|
import { findTargetElementFromEvent } from "../../dom/events.mjs";
|
29
29
|
import { isFunction, isObject } from "../../types/is.mjs";
|
@@ -82,226 +82,226 @@ const detectedLanguagesSymbol = Symbol("detectedLanguages");
|
|
82
82
|
* @summary A beautiful LocalePicker that can make your life easier and also looks good.
|
83
83
|
*/
|
84
84
|
class LocalePicker extends CustomElement {
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
85
|
+
/**
|
86
|
+
* This method is called by the `instanceof` operator.
|
87
|
+
* @returns {symbol}
|
88
|
+
*/
|
89
|
+
static get [instanceSymbol]() {
|
90
|
+
return Symbol.for(
|
91
|
+
"@schukai/monster/components/accessibility/locale-picker@@instance",
|
92
|
+
);
|
93
|
+
}
|
94
|
+
|
95
|
+
/**
|
96
|
+
*
|
97
|
+
* @return {LocalePicker}
|
98
|
+
*/
|
99
|
+
[assembleMethodSymbol]() {
|
100
|
+
super[assembleMethodSymbol]();
|
101
|
+
initControlReferences.call(this);
|
102
|
+
initEventHandler.call(this);
|
103
|
+
|
104
|
+
return this;
|
105
|
+
}
|
106
|
+
|
107
|
+
/**
|
108
|
+
* To set the options via the HTML Tag, the attribute `data-monster-options` must be used.
|
109
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
110
|
+
*
|
111
|
+
* The individual configuration values can be found in the table.
|
112
|
+
*
|
113
|
+
* @property {Object} templates Template definitions
|
114
|
+
* @property {string} templates.main Main template
|
115
|
+
* @property {Object} labels Label definitions
|
116
|
+
* @property {string} labels.headline Headline
|
117
|
+
* @property {string} labels.text Text
|
118
|
+
* @property {string} labels.button-label Button label
|
119
|
+
* @property {string} labels.button-no-thanks Button no thanks
|
120
|
+
* @property {string} labels.headline-other Headline other languages
|
121
|
+
* @property {Function} callbacks.getTranslation Callback to get the translation for the labels
|
122
|
+
* @property {Object} features Features
|
123
|
+
* @property {boolean} features.removeOnSelected Remove the element when a language is selected
|
124
|
+
* @property {boolean} features.showAlways Show the element always
|
125
|
+
* @property {boolean} disabled Disabled state
|
126
|
+
*/
|
127
|
+
get defaults() {
|
128
|
+
return Object.assign({}, super.defaults, {
|
129
|
+
templates: {
|
130
|
+
main: getTemplate(),
|
131
|
+
},
|
132
|
+
labels: {
|
133
|
+
headline: "Welcome to our Website",
|
134
|
+
text: "This page is currently displayed in ${currentLabel}. However, we also offer this page in your preferred language. Would you like to switch?",
|
135
|
+
"button-label": "Switch to ${preferred.label}",
|
136
|
+
"button-no-thanks": "No, thanks",
|
137
|
+
"headline-other": "Other languages",
|
138
|
+
},
|
139
|
+
|
140
|
+
callbacks: {
|
141
|
+
getTranslation: getTranslations,
|
142
|
+
},
|
143
|
+
|
144
|
+
disabled: false,
|
145
|
+
features: {
|
146
|
+
removeOnSelected: false,
|
147
|
+
showAlways: false,
|
148
|
+
},
|
149
|
+
});
|
150
|
+
}
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Private method that provides a mapping of transformer methods keyed by their names.
|
154
|
+
* These transformer methods define custom transformations for given input values.
|
155
|
+
*
|
156
|
+
* @private
|
157
|
+
* @return {Object} An object containing transformer methods for internal use.
|
158
|
+
*/
|
159
|
+
[updaterTransformerMethodsSymbol]() {
|
160
|
+
return {
|
161
|
+
"replace-placeholder": (value) => {
|
162
|
+
const formatter = new Formatter(this[detectedLanguagesSymbol]);
|
163
|
+
return formatter.format(value);
|
164
|
+
},
|
165
|
+
};
|
166
|
+
}
|
167
|
+
|
168
|
+
/**
|
169
|
+
* Lifecycle method that is called when the custom element is appended into a document-connected element.
|
170
|
+
* Invokes the parent class's connectedCallback method and retrieves the user's preferred language.
|
171
|
+
* Logs the preferred language to the console.
|
172
|
+
*
|
173
|
+
* @return {void}
|
174
|
+
*/
|
175
|
+
connectedCallback() {
|
176
|
+
super.connectedCallback();
|
177
|
+
|
178
|
+
this[detectedLanguagesSymbol] = detectUserLanguagePreference();
|
179
|
+
|
180
|
+
if (
|
181
|
+
!isObject(this[detectedLanguagesSymbol]?.preferred) &&
|
182
|
+
this.getOption("features.showAlways") !== true
|
183
|
+
) {
|
184
|
+
this.hide();
|
185
|
+
|
186
|
+
if (this.getOption("features.removeOnSelected")) {
|
187
|
+
this.remove();
|
188
|
+
}
|
189
|
+
return;
|
190
|
+
}
|
191
|
+
|
192
|
+
if (!isObject(this[detectedLanguagesSymbol]?.preferred)) {
|
193
|
+
this[detectedLanguagesSymbol].preferred = {
|
194
|
+
fullLang: "en",
|
195
|
+
baseLang: "en",
|
196
|
+
label: "English",
|
197
|
+
};
|
198
|
+
}
|
199
|
+
|
200
|
+
const stored = localStorage.getItem(buildStorageKey.call(this));
|
201
|
+
if (stored && this.getOption("features.showAlways") !== true) {
|
202
|
+
if (this.getOption("features.removeOnSelected")) {
|
203
|
+
this.remove();
|
204
|
+
}
|
205
|
+
return;
|
206
|
+
}
|
207
|
+
|
208
|
+
this.show();
|
209
|
+
|
210
|
+
if (
|
211
|
+
this[otherLanguagesElementSymbol] instanceof HTMLElement &&
|
212
|
+
this[detectedLanguagesSymbol].offerable &&
|
213
|
+
this[detectedLanguagesSymbol].offerable.length > 1
|
214
|
+
) {
|
215
|
+
this[otherLanguagesElementSymbol].classList.remove("hidden");
|
216
|
+
this[otherLanguagesElementSymbol].setOption(
|
217
|
+
"mapping.labelTemplate",
|
218
|
+
"${label}",
|
219
|
+
);
|
220
|
+
this[otherLanguagesElementSymbol].setOption(
|
221
|
+
"mapping.valueTemplate",
|
222
|
+
"${href}",
|
223
|
+
);
|
224
|
+
this[otherLanguagesElementSymbol].importOptions(
|
225
|
+
this[detectedLanguagesSymbol]?.offerable || [],
|
226
|
+
);
|
227
|
+
}
|
228
|
+
|
229
|
+
if (
|
230
|
+
this[detectedLanguagesSymbol].offerable &&
|
231
|
+
this[detectedLanguagesSymbol].offerable.length > 0
|
232
|
+
) {
|
233
|
+
const getTranslationCallback = this.getOption("callbacks.getTranslation");
|
234
|
+
if (isFunction(getTranslationCallback)) {
|
235
|
+
const translations = getTranslationCallback(
|
236
|
+
this[detectedLanguagesSymbol].offerable[0].baseLang,
|
237
|
+
);
|
238
|
+
|
239
|
+
this.setOption("labels", translations.labels);
|
240
|
+
if (this[otherLanguagesElementSymbol]) {
|
241
|
+
this[otherLanguagesElementSymbol].setOption(
|
242
|
+
"labels.select-an-option",
|
243
|
+
translations.selectAnOption,
|
244
|
+
);
|
245
|
+
}
|
246
|
+
}
|
247
|
+
}
|
248
|
+
}
|
249
|
+
|
250
|
+
/**
|
251
|
+
* Resets the locale picker by removing the stored value from the local storage.
|
252
|
+
*
|
253
|
+
* @returns {LocalePicker}
|
254
|
+
*/
|
255
|
+
reset() {
|
256
|
+
localStorage.removeItem(buildStorageKey.call(this));
|
257
|
+
this.show();
|
258
|
+
return this;
|
259
|
+
}
|
260
|
+
|
261
|
+
/**
|
262
|
+
* Hides the locale picker.
|
263
|
+
*
|
264
|
+
* @returns {LocalePicker}
|
265
|
+
*/
|
266
|
+
hide() {
|
267
|
+
this.style.display = "none";
|
268
|
+
|
269
|
+
if (!this[localePickerElementSymbol]) {
|
270
|
+
return this;
|
271
|
+
}
|
272
|
+
|
273
|
+
this[localePickerElementSymbol].style.display = "none";
|
274
|
+
return this;
|
275
|
+
}
|
276
|
+
|
277
|
+
/**
|
278
|
+
* Shows the locale picker.
|
279
|
+
* @returns {LocalePicker}
|
280
|
+
*/
|
281
|
+
show() {
|
282
|
+
this.style.display = "block";
|
283
|
+
|
284
|
+
if (!this[localePickerElementSymbol]) {
|
285
|
+
return this;
|
286
|
+
}
|
287
|
+
|
288
|
+
this[localePickerElementSymbol].style.display = "block";
|
289
|
+
return this;
|
290
|
+
}
|
291
|
+
|
292
|
+
/**
|
293
|
+
* @return {string}
|
294
|
+
*/
|
295
|
+
static getTag() {
|
296
|
+
return "monster-locale-picker";
|
297
|
+
}
|
298
|
+
|
299
|
+
/**
|
300
|
+
* @return {CSSStyleSheet[]}
|
301
|
+
*/
|
302
|
+
static getCSSStyleSheet() {
|
303
|
+
return [LocalePickerStyleSheet];
|
304
|
+
}
|
305
305
|
}
|
306
306
|
|
307
307
|
/**
|
@@ -309,65 +309,65 @@ class LocalePicker extends CustomElement {
|
|
309
309
|
* @return {initEventHandler}
|
310
310
|
*/
|
311
311
|
function initEventHandler() {
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
312
|
+
const self = this;
|
313
|
+
const element = this[localePickerElementSymbol];
|
314
|
+
|
315
|
+
const type = "click";
|
316
|
+
|
317
|
+
element.addEventListener(type, function (event) {
|
318
|
+
const callback = self.getOption("actions.click");
|
319
|
+
|
320
|
+
fireCustomEvent(self, "monster-locale-picker-clicked", {
|
321
|
+
element: self,
|
322
|
+
});
|
323
|
+
|
324
|
+
if (!isFunction(callback)) {
|
325
|
+
return;
|
326
|
+
}
|
327
|
+
|
328
|
+
const element = findTargetElementFromEvent(
|
329
|
+
event,
|
330
|
+
ATTRIBUTE_ROLE,
|
331
|
+
"control",
|
332
|
+
);
|
333
|
+
|
334
|
+
if (!(element instanceof Node && self.hasNode(element))) {
|
335
|
+
return;
|
336
|
+
}
|
337
|
+
|
338
|
+
callback.call(self, event);
|
339
|
+
});
|
340
|
+
|
341
|
+
this[buttonNoThanksElementSymbol].setOption("actions.click", () => {
|
342
|
+
localStorage.setItem(buildStorageKey.call(this), "1");
|
343
|
+
this.hide();
|
344
|
+
if (this.getOption("features.removeOnSelected")) {
|
345
|
+
this.remove();
|
346
|
+
}
|
347
|
+
});
|
348
|
+
|
349
|
+
this[buttonLanguageElementSymbol].setOption("actions.click", () => {
|
350
|
+
localStorage.setItem(buildStorageKey.call(this), "1");
|
351
|
+
window.location.href = this[detectedLanguagesSymbol].offerable?.[0]?.href;
|
352
|
+
});
|
353
|
+
|
354
|
+
this[otherLanguagesElementSymbol].addEventListener("change", (event) => {
|
355
|
+
const element = findTargetElementFromEvent(
|
356
|
+
event,
|
357
|
+
ATTRIBUTE_ROLE,
|
358
|
+
"other-languages",
|
359
|
+
);
|
360
|
+
|
361
|
+
if (element) {
|
362
|
+
const selected = element?.value;
|
363
|
+
if (selected) {
|
364
|
+
localStorage.setItem(buildStorageKey.call(this), "1");
|
365
|
+
window.location.href = selected;
|
366
|
+
}
|
367
|
+
}
|
368
|
+
});
|
369
|
+
|
370
|
+
return this;
|
371
371
|
}
|
372
372
|
|
373
373
|
/**
|
@@ -375,7 +375,7 @@ function initEventHandler() {
|
|
375
375
|
* @returns {string}
|
376
376
|
*/
|
377
377
|
function buildStorageKey() {
|
378
|
-
|
378
|
+
return "locale-picker-" + this[detectedLanguagesSymbol].current;
|
379
379
|
}
|
380
380
|
|
381
381
|
/**
|
@@ -384,244 +384,244 @@ function buildStorageKey() {
|
|
384
384
|
* @returns {Object}
|
385
385
|
*/
|
386
386
|
function getTranslations(lang) {
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
387
|
+
const map = {
|
388
|
+
en: {
|
389
|
+
headline: "Welcome to our Website",
|
390
|
+
text: "This page is currently displayed in ${currentLabel}. However, we also offer this page in your preferred language. Would you like to switch?",
|
391
|
+
"button-label": "Switch to ${preferred.label}",
|
392
|
+
"button-no-thanks": "No, thanks",
|
393
|
+
"headline-other": "Other languages",
|
394
|
+
},
|
395
|
+
de: {
|
396
|
+
headline: "Willkommen auf unserer Webseite",
|
397
|
+
text: "Diese Seite wird aktuell auf ${currentLabel} angezeigt. Wir bieten jedoch auch diese Seite in Ihrer bevorzugten Sprache an. Möchten Sie wechseln?",
|
398
|
+
"button-label": "Wechseln zu ${preferred.label}",
|
399
|
+
"button-no-thanks": "Nein, danke",
|
400
|
+
"headline-other": "Andere Sprachen",
|
401
|
+
},
|
402
|
+
fr: {
|
403
|
+
headline: "Bienvenue sur notre site web",
|
404
|
+
text: "Cette page est actuellement affichée en ${currentLabel}. Cependant, nous proposons également cette page dans votre langue préférée. Souhaitez-vous changer?",
|
405
|
+
"button-label": "Changer pour ${preferred.label}",
|
406
|
+
"button-no-thanks": "Non, merci",
|
407
|
+
"headline-other": "Autres langues",
|
408
|
+
},
|
409
|
+
es: {
|
410
|
+
headline: "Bienvenido a nuestro sitio web",
|
411
|
+
text: "Esta página se muestra actualmente en ${currentLabel}. Sin embargo, también ofrecemos esta página en su idioma preferido. ¿Le gustaría cambiar?",
|
412
|
+
"button-label": "Cambiar a ${preferred.label}",
|
413
|
+
"button-no-thanks": "No, gracias",
|
414
|
+
"headline-other": "Otros idiomas",
|
415
|
+
},
|
416
|
+
it: {
|
417
|
+
headline: "Benvenuti sul nostro sito web",
|
418
|
+
text: "Questa pagina è attualmente visualizzata in ${currentLabel}. Tuttavia, offriamo anche questa pagina nella tua lingua preferita. Vuoi cambiare?",
|
419
|
+
"button-label": "Cambia nella ${preferred.label}",
|
420
|
+
"button-no-thanks": "No, grazie",
|
421
|
+
"headline-other": "Altre lingue",
|
422
|
+
},
|
423
|
+
pt: {
|
424
|
+
headline: "Bem-vindo ao nosso site",
|
425
|
+
text: "Esta página está atualmente exibida em ${currentLabel}. No entanto, também oferecemos esta página no seu idioma preferido. Gostaria de mudar?",
|
426
|
+
"button-label": "Mudar para ${preferred.label}",
|
427
|
+
"button-no-thanks": "Não, obrigado",
|
428
|
+
"headline-other": "Outros idiomas",
|
429
|
+
},
|
430
|
+
nl: {
|
431
|
+
headline: "Welkom op onze website",
|
432
|
+
text: "Deze pagina wordt momenteel weergegeven in ${currentLabel}. We bieden deze pagina echter ook aan in uw voorkeurstaal. Wilt u overschakelen?",
|
433
|
+
"button-label": "Overschakelen naar ${preferred.label}",
|
434
|
+
"button-no-thanks": "Nee, bedankt",
|
435
|
+
"headline-other": "Andere talen",
|
436
|
+
},
|
437
|
+
pl: {
|
438
|
+
headline: "Witamy na naszej stronie",
|
439
|
+
text: "Ta strona jest obecnie wyświetlana po ${currentLabel}. Oferujemy jednak również tę stronę w Twoim preferowanym języku. Czy chcesz przełączyć?",
|
440
|
+
"button-label": "Przełącz na ${preferred.label}",
|
441
|
+
"button-no-thanks": "Nie, dziękuję",
|
442
|
+
"headline-other": "Inne języki",
|
443
|
+
},
|
444
|
+
ru: {
|
445
|
+
headline: "Добро пожаловать на наш сайт",
|
446
|
+
text: "Эта страница в настоящее время отображается на ${currentLabel}. Однако мы также предлагаем эту страницу на вашем предпочтительном языке. Хотите переключиться?",
|
447
|
+
"button-label": "Переключиться на ${preferred.label}",
|
448
|
+
"button-no-thanks": "Нет, спасибо",
|
449
|
+
"headline-other": "Другие языки",
|
450
|
+
},
|
451
|
+
cs: {
|
452
|
+
headline: "Vítejte na našem webu",
|
453
|
+
text: "Tato stránka je aktuálně zobrazena v ${currentLabel}. Nabízíme však tuto stránku také ve vašem preferovaném jazyce. Chcete přejít?",
|
454
|
+
"button-label": "Přejít na ${preferred.label}",
|
455
|
+
"button-no-thanks": "Ne, děkuji",
|
456
|
+
"headline-other": "Další jazyky",
|
457
|
+
},
|
458
|
+
sk: {
|
459
|
+
headline: "Vitajte na našej webovej stránke",
|
460
|
+
text: "Táto stránka je v súčasnosti zobrazená v ${currentLabel}. Ponúkame však túto stránku aj vo vašom preferovanom jazyku. Chcete prejsť?",
|
461
|
+
"button-label": "Prepnúť na ${preferred.label}",
|
462
|
+
"button-no-thanks": "Nie, ďakujem",
|
463
|
+
"headline-other": "Iné jazyky",
|
464
|
+
},
|
465
|
+
|
466
|
+
bg: {
|
467
|
+
headline: "Добре дошли на нашия уебсайт",
|
468
|
+
text: "Тази страница в момента се показва на ${currentLabel}. Въпреки това, предлагаме също тази страница на Вашия предпочитан език. Желаете ли да превключите?",
|
469
|
+
"button-label": "Превключете на ${preferred.label}",
|
470
|
+
"button-no-thanks": "Не, благодаря",
|
471
|
+
"headline-other": "Други езици",
|
472
|
+
},
|
473
|
+
hr: {
|
474
|
+
headline: "Dobrodošli na našu web stranicu",
|
475
|
+
text: "Ova stranica trenutno je prikazana na ${currentLabel}. Međutim, nudimo i ovu stranicu na vašem preferiranom jeziku. Želite li prebaciti?",
|
476
|
+
"button-label": "Prebaci na ${preferred.label}",
|
477
|
+
"button-no-thanks": "Ne, hvala",
|
478
|
+
"headline-other": "Drugi jezici",
|
479
|
+
},
|
480
|
+
fi: {
|
481
|
+
headline: "Tervetuloa verkkosivustollemme",
|
482
|
+
text: "Tämä sivu on tällä hetkellä näkyvissä ${currentLabel}. Tarjoamme kuitenkin tätä sivua myös suosimallasi kielellä. Haluaisitko vaihtaa?",
|
483
|
+
"button-label": "Vaihda ${preferred.label}",
|
484
|
+
"button-no-thanks": "Ei kiitos",
|
485
|
+
"headline-other": "Muut kielet",
|
486
|
+
},
|
487
|
+
sv: {
|
488
|
+
headline: "Välkommen till vår webbplats",
|
489
|
+
text: "Denna sida visas för närvarande på ${currentLabel}. Vi erbjuder dock även denna sida på ditt föredragna språk. Skulle du vilja byta?",
|
490
|
+
"button-label": "Byt till ${preferred.label}",
|
491
|
+
"button-no-thanks": "Nej tack",
|
492
|
+
"headline-other": "Andra språk",
|
493
|
+
},
|
494
|
+
el: {
|
495
|
+
headline: "Καλώς ήρθατε στην ιστοσελίδα μας",
|
496
|
+
text: "Αυτή η σελίδα εμφανίζεται προς το παρόν στα ${currentLabel}. Ωστόσο, προσφέρουμε επίσης αυτή τη σελίδα στην προτιμώμενη γλώσσα σας. Θα θέλατε να αλλάξετε;",
|
497
|
+
"button-label": "Αλλαγή σε ${preferred.label}",
|
498
|
+
"button-no-thanks": "Όχι, ευχαριστώ",
|
499
|
+
"headline-other": "Άλλες γλώσσες",
|
500
|
+
},
|
501
|
+
hu: {
|
502
|
+
headline: "Üdvözöljük weboldalunkon",
|
503
|
+
text: "Ez az oldal jelenleg ${currentLabel} nyelven jelenik meg. Azonban kínáljuk ezt az oldalt a preferált nyelvén is. Szeretne váltani?",
|
504
|
+
"button-label": "Váltás ${preferred.label} nyelvre",
|
505
|
+
"button-no-thanks": "Nem, köszönöm",
|
506
|
+
"headline-other": "További nyelvek",
|
507
|
+
},
|
508
|
+
ro: {
|
509
|
+
headline: "Bine ați venit pe site-ul nostru",
|
510
|
+
text: "Această pagină este afișată în prezent în ${currentLabel}. Totuși, oferim de asemenea această pagină în limba dumneavoastră preferată. Doriți să schimbați?",
|
511
|
+
"button-label": "Schimbați în ${preferred.label}",
|
512
|
+
"button-no-thanks": "Nu, mulțumesc",
|
513
|
+
"headline-other": "Alte limbi",
|
514
|
+
},
|
515
|
+
da: {
|
516
|
+
headline: "Velkommen til vores hjemmeside",
|
517
|
+
text: "Denne side vises i øjeblikket på ${currentLabel}. Vi tilbyder dog også denne side på dit foretrukne sprog. Vil du skifte?",
|
518
|
+
"button-label": "Skift til ${preferred.label}",
|
519
|
+
"button-no-thanks": "Nej tak",
|
520
|
+
"headline-other": "Andre sprog",
|
521
|
+
},
|
522
|
+
no: {
|
523
|
+
headline: "Velkommen til vår nettside",
|
524
|
+
text: "Denne siden vises for øyeblikket på ${currentLabel}. Vi tilbyr imidlertid også denne siden på ditt foretrukne språk. Ønsker du å bytte?",
|
525
|
+
"button-label": "Bytt til ${preferred.label}",
|
526
|
+
"button-no-thanks": "Nei, takk",
|
527
|
+
"headline-other": "Andre språk",
|
528
|
+
},
|
529
|
+
hi: {
|
530
|
+
headline: "हमारी वेबसाइट पर आपका स्वागत है",
|
531
|
+
text: "यह पृष्ठ वर्तमान में ${currentLabel} में प्रदर्शित हो रहा है। हालांकि, हम इस पृष्ठ को आपकी पसंदीदा भाषा में भी प्रदान करते हैं। क्या आप स्विच करना चाहेंगे?",
|
532
|
+
"button-label": "${preferred.label} में स्विच करें",
|
533
|
+
"button-no-thanks": "नहीं, धन्यवाद",
|
534
|
+
"headline-other": "अन्य भाषाएँ",
|
535
|
+
},
|
536
|
+
bn: {
|
537
|
+
headline: "আমাদের ওয়েবসাইটে আপনাকে স্বাগতম",
|
538
|
+
text: "এই পৃষ্ঠাটি বর্তমানে ${currentLabel} প্রদর্শিত হচ্ছে। তবে, আমরা এই পৃষ্ঠাটি আপনার পছন্দের ভাষায়ও অফার করি। আপনি কি সুইচ করতে চান?",
|
539
|
+
"button-label": "${preferred.label}-এ সুইচ করুন",
|
540
|
+
"button-no-thanks": "না, ধন্যবাদ",
|
541
|
+
"headline-other": "অন্যান্য ভাষাসমূহ",
|
542
|
+
},
|
543
|
+
ta: {
|
544
|
+
headline: "எங்கள் இணையதளத்திற்கு வருக",
|
545
|
+
text: "இந்த பக்கம் தற்போது ${currentLabel} என்ற மொழியில் காட்சியளிக்கப்படுகிறது. எனினும், நாங்கள் இந்த பக்கத்தை உங்கள் விருப்ப மொழியிலும் வழங்குகிறோம். நீங்கள் மாற்ற விரும்புகிறீர்களா?",
|
546
|
+
"button-label": "${preferred.label}-க்கு மாற்றவும்",
|
547
|
+
"button-no-thanks": "இல்லை, நன்றி",
|
548
|
+
"headline-other": "மற்ற மொழிகள்",
|
549
|
+
},
|
550
|
+
te: {
|
551
|
+
headline: "మా వెబ్సైట్కు స్వాగతం",
|
552
|
+
text: "ఈ పేజీ ప్రస్తుతం ${currentLabel}లో ప్రదర్శితం అవుతున్నది. అయితే, మేము ఈ పేజీని మీ ఇష్టపడే భాషలో కూడా అందిస్తున్నాము. మీరు మార్చాలనుకుంటున్నారా?",
|
553
|
+
"button-label": "${preferred.label}కి మార్చండి",
|
554
|
+
"button-no-thanks": "కాదు, ధన్యవాదాలు",
|
555
|
+
"headline-other": "ఇతర భాషలు",
|
556
|
+
},
|
557
|
+
mr: {
|
558
|
+
headline: "आपले आमच्या वेबसाइटवर स्वागत आहे",
|
559
|
+
text: "हे पान सध्या ${currentLabel}मध्ये दाखविले जात आहे. परंतु, आम्ही हे पान आपल्या पसंतीच्या भाषेतही देत आहोत. आपण स्विच करू इच्छिता का?",
|
560
|
+
"button-label": "${preferred.label}मध्ये स्विच करा",
|
561
|
+
"button-no-thanks": "नाही, धन्यवाद",
|
562
|
+
"headline-other": "इतर भाषा",
|
563
|
+
},
|
564
|
+
zh: {
|
565
|
+
headline: "欢迎访问我们的网站",
|
566
|
+
text: "本页面当前显示为${currentLabel}。然而,我们还提供您偏好的语言版本。您想切换吗?",
|
567
|
+
"button-label": "切换到${preferred.label}",
|
568
|
+
"button-no-thanks": "不,谢谢",
|
569
|
+
"headline-other": "其他语言",
|
570
|
+
},
|
571
|
+
ja: {
|
572
|
+
headline: "私たちのウェブサイトへようこそ",
|
573
|
+
text: "このページは現在${currentLabel}で表示されています。しかし、私たちはあなたの好みの言語でこのページを提供しています。切り替えますか?",
|
574
|
+
"button-label": "${preferred.label}に切り替える",
|
575
|
+
"button-no-thanks": "いいえ、結構です",
|
576
|
+
"headline-other": "他の言語",
|
577
|
+
},
|
578
|
+
};
|
579
|
+
|
580
|
+
const selectAnOption = {
|
581
|
+
en: "Select a language",
|
582
|
+
de: "Wählen Sie eine Sprache",
|
583
|
+
fr: "Sélectionnez une langue",
|
584
|
+
es: "Seleccione un idioma",
|
585
|
+
it: "Seleziona una lingua",
|
586
|
+
pt: "Selecione um idioma",
|
587
|
+
nl: "Selecteer een taal",
|
588
|
+
pl: "Wybierz język",
|
589
|
+
ru: "Выберите язык",
|
590
|
+
cs: "Vyberte jazyk",
|
591
|
+
sk: "Vyberte jazyk",
|
592
|
+
bg: "Изберете език",
|
593
|
+
hr: "Odaberite jezik",
|
594
|
+
fi: "Valitse kieli",
|
595
|
+
sv: "Välj ett språk",
|
596
|
+
el: "Επιλέξτε γλώσσα",
|
597
|
+
hu: "Válasszon egy nyelvet",
|
598
|
+
ro: "Selectați o limbă",
|
599
|
+
da: "Vælg et sprog",
|
600
|
+
no: "Velg et språk",
|
601
|
+
hi: "एक भाषा चुनें",
|
602
|
+
bn: "একটি ভাষা নির্বাচন করুন",
|
603
|
+
ta: "ஒரு மொழியைத் தேர்ந்தெடுக்கவும்",
|
604
|
+
te: "భాషను ఎంచుకోండి",
|
605
|
+
mr: "एक भाषा निवडा",
|
606
|
+
zh: "选择一种语言",
|
607
|
+
ja: "言語を選択してください",
|
608
|
+
};
|
609
|
+
|
610
|
+
const result = {};
|
611
|
+
|
612
|
+
if (map[lang]) {
|
613
|
+
result["labels"] = map[lang];
|
614
|
+
} else {
|
615
|
+
result["labels"] = map["en"];
|
616
|
+
}
|
617
|
+
|
618
|
+
if (selectAnOption[lang]) {
|
619
|
+
result["selectAnOption"] = selectAnOption[lang];
|
620
|
+
} else {
|
621
|
+
result["selectAnOption"] = selectAnOption["en"];
|
622
|
+
}
|
623
|
+
|
624
|
+
return result;
|
625
625
|
}
|
626
626
|
|
627
627
|
/**
|
@@ -629,21 +629,21 @@ function getTranslations(lang) {
|
|
629
629
|
* @return {void}
|
630
630
|
*/
|
631
631
|
function initControlReferences() {
|
632
|
-
|
633
|
-
|
634
|
-
|
632
|
+
this[localePickerElementSymbol] = this.shadowRoot.querySelector(
|
633
|
+
`[${ATTRIBUTE_ROLE}="control"]`,
|
634
|
+
);
|
635
635
|
|
636
|
-
|
637
|
-
|
638
|
-
|
636
|
+
this[otherLanguagesElementSymbol] = this.shadowRoot.querySelector(
|
637
|
+
`[${ATTRIBUTE_ROLE}="other-languages"]`,
|
638
|
+
);
|
639
639
|
|
640
|
-
|
641
|
-
|
642
|
-
|
640
|
+
this[buttonNoThanksElementSymbol] = this.shadowRoot.querySelector(
|
641
|
+
`[${ATTRIBUTE_ROLE}="button-no-thanks"]`,
|
642
|
+
);
|
643
643
|
|
644
|
-
|
645
|
-
|
646
|
-
|
644
|
+
this[buttonLanguageElementSymbol] = this.shadowRoot.querySelector(
|
645
|
+
`[${ATTRIBUTE_ROLE}="button-language"]`,
|
646
|
+
);
|
647
647
|
}
|
648
648
|
|
649
649
|
/**
|
@@ -651,15 +651,15 @@ function initControlReferences() {
|
|
651
651
|
* @return {string}
|
652
652
|
*/
|
653
653
|
function getTemplate() {
|
654
|
-
|
655
|
-
|
654
|
+
// language=HTML
|
655
|
+
return `
|
656
656
|
<div data-monster-role="control" part="control">
|
657
657
|
<h2 data-monster-role="headline" part="headline" data-monster-replace="path:labels.headline"></h2>
|
658
|
-
<p data-monster-replace="path:labels.text | call:replace-placeholder"></p>
|
658
|
+
<p part="text" data-monster-replace="path:labels.text | call:replace-placeholder"></p>
|
659
659
|
<div data-monster-role="container" part="container">
|
660
|
-
<monster-button data-monster-role="button-language"
|
660
|
+
<monster-button data-monster-role="button-language" part="button-language"
|
661
661
|
data-monster-replace="path:labels.button-label | call:replace-placeholder"></monster-button>
|
662
|
-
<monster-button data-monster-role="button-no-thanks"
|
662
|
+
<monster-button data-monster-role="button-no-thanks" part="button-no-thanks"
|
663
663
|
data-monster-replace="path:labels.button-no-thanks | call:replace-placeholder"></monster-button>
|
664
664
|
<monster-select class="hidden" data-monster-role="other-languages"></monster-select>
|
665
665
|
</div>
|