@4site/engrid-scripts 0.27.6 → 0.28.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/a11y.js +4 -1
- package/dist/data-attributes.js +4 -0
- package/dist/engrid.d.ts +4 -0
- package/dist/engrid.js +47 -0
- package/dist/events/donation-amount.d.ts +2 -0
- package/dist/events/donation-amount.js +20 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/i18n-options.d.ts +6 -0
- package/dist/interfaces/i18n-options.js +30 -0
- package/dist/interfaces/translate-options.js +16 -0
- package/dist/other-amount.js +5 -0
- package/dist/remember-me.js +8 -8
- package/dist/translate-fields.d.ts +1 -0
- package/dist/translate-fields.js +52 -16
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -3
package/dist/a11y.js
CHANGED
|
@@ -364,7 +364,10 @@ export class A11y {
|
|
|
364
364
|
}
|
|
365
365
|
else {
|
|
366
366
|
const cleaned = allMessages.map(message => message.replace(/[.!?]+$/, '').trim());
|
|
367
|
-
region.textContent =
|
|
367
|
+
region.textContent = ENGrid.t("a11y.errorSummary", {
|
|
368
|
+
count: allMessages.length,
|
|
369
|
+
messages: cleaned.join('. '),
|
|
370
|
+
});
|
|
368
371
|
}
|
|
369
372
|
if (this.shouldFocusFirstInvalidField) {
|
|
370
373
|
this.shouldFocusFirstInvalidField = false;
|
package/dist/data-attributes.js
CHANGED
|
@@ -19,6 +19,10 @@ export class DataAttributes {
|
|
|
19
19
|
if (ENGrid.checkNested(window, "pageJson", "pageType")) {
|
|
20
20
|
ENGrid.setBodyData("page-type", window.pageJson.pageType);
|
|
21
21
|
}
|
|
22
|
+
// Add the locale as a Data Attribute on the Body Tag
|
|
23
|
+
if (ENGrid.checkNested(window, "pageJson", "locale")) {
|
|
24
|
+
ENGrid.setBodyData("locale", window.pageJson.locale.toLowerCase());
|
|
25
|
+
}
|
|
22
26
|
// Add the currency code as a Data Attribute on the Body Tag
|
|
23
27
|
ENGrid.setBodyData("currency-code", ENGrid.getCurrencyCode());
|
|
24
28
|
// Add a body banner data attribute if the banner contains no image or video
|
package/dist/engrid.d.ts
CHANGED
|
@@ -28,6 +28,10 @@ export declare abstract class ENGrid {
|
|
|
28
28
|
static getClientID(): any;
|
|
29
29
|
static getDataCenter(): "us2" | "us" | "ca";
|
|
30
30
|
static getPageType(): "DONATION" | "ECARD" | "SURVEY" | "EMAILTOTARGET" | "ADVOCACY" | "SUBSCRIBEFORM" | "EVENT" | "SUPPORTERHUB" | "UNSUBSCRIBE" | "TWEETPAGE" | "UNKNOWN";
|
|
31
|
+
static getPageLanguage(): string;
|
|
32
|
+
private static getI18nDictionaries;
|
|
33
|
+
static hasI18nKey(key: string): boolean;
|
|
34
|
+
static t(key: string, replacements?: Record<string, string | number>): string;
|
|
31
35
|
static setBodyData(dataName: string, value: string | boolean): void;
|
|
32
36
|
static getBodyData(dataName: string): string | null;
|
|
33
37
|
static hasBodyData(dataName: string): boolean;
|
package/dist/engrid.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { I18nDefaults } from "./interfaces/i18n-options";
|
|
1
2
|
const errorCallbacks = new Map();
|
|
2
3
|
export class ENGrid {
|
|
3
4
|
constructor() {
|
|
@@ -261,6 +262,52 @@ export class ENGrid {
|
|
|
261
262
|
return "UNKNOWN";
|
|
262
263
|
}
|
|
263
264
|
}
|
|
265
|
+
// Return the current page language: the first 2 characters of
|
|
266
|
+
// pageJson.locale, lowercased (e.g. "es_US" -> "es"). Defaults to "en"
|
|
267
|
+
// when pageJson or the locale is not available.
|
|
268
|
+
static getPageLanguage() {
|
|
269
|
+
var _a;
|
|
270
|
+
const locale = (_a = window.pageJson) === null || _a === void 0 ? void 0 : _a.locale;
|
|
271
|
+
if (typeof locale === "string" && locale.length >= 2) {
|
|
272
|
+
return locale.substring(0, 2).toLowerCase();
|
|
273
|
+
}
|
|
274
|
+
return "en";
|
|
275
|
+
}
|
|
276
|
+
// Return the merged i18n dictionaries: window.EngridI18n merged over
|
|
277
|
+
// I18nDefaults, key-by-key per language, without mutating the defaults.
|
|
278
|
+
static getI18nDictionaries() {
|
|
279
|
+
const dictionaries = Object.assign({}, I18nDefaults);
|
|
280
|
+
if ("EngridI18n" in window && window.EngridI18n) {
|
|
281
|
+
for (const lang in window.EngridI18n) {
|
|
282
|
+
dictionaries[lang] = Object.assign(Object.assign({}, (I18nDefaults[lang] || {})), window.EngridI18n[lang]);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return dictionaries;
|
|
286
|
+
}
|
|
287
|
+
// Check if an i18n key is defined in the merged dictionary for the current
|
|
288
|
+
// page language (the English fallback does not count).
|
|
289
|
+
static hasI18nKey(key) {
|
|
290
|
+
var _a;
|
|
291
|
+
const language = ENGrid.getPageLanguage();
|
|
292
|
+
return key in ((_a = ENGrid.getI18nDictionaries()[language]) !== null && _a !== void 0 ? _a : {});
|
|
293
|
+
}
|
|
294
|
+
// Translate a UI string key using the i18n dictionary: I18nDefaults merged
|
|
295
|
+
// with the window.EngridI18n global (key-by-key, per language, without
|
|
296
|
+
// mutating the defaults). Resolution order: current page language bucket ->
|
|
297
|
+
// English bucket -> the key itself. {placeholders} are interpolated from
|
|
298
|
+
// the replacements argument.
|
|
299
|
+
static t(key, replacements = {}) {
|
|
300
|
+
var _a, _b, _c, _d;
|
|
301
|
+
const dictionaries = ENGrid.getI18nDictionaries();
|
|
302
|
+
const language = ENGrid.getPageLanguage();
|
|
303
|
+
let text = (_d = (_b = (_a = dictionaries[language]) === null || _a === void 0 ? void 0 : _a[key]) !== null && _b !== void 0 ? _b : (_c = dictionaries["en"]) === null || _c === void 0 ? void 0 : _c[key]) !== null && _d !== void 0 ? _d : key;
|
|
304
|
+
for (const name in replacements) {
|
|
305
|
+
// Function replacement: the value is inserted literally, so $-sequences
|
|
306
|
+
// ($&, $$, ...) in user-facing text are never interpreted.
|
|
307
|
+
text = text.replace(new RegExp(`\\{${name}\\}`, "g"), () => String(replacements[name]));
|
|
308
|
+
}
|
|
309
|
+
return text;
|
|
310
|
+
}
|
|
264
311
|
// Set body engrid data attributes
|
|
265
312
|
static setBodyData(dataName, value) {
|
|
266
313
|
const body = document.querySelector("body");
|
|
@@ -6,6 +6,8 @@ export declare class DonationAmount {
|
|
|
6
6
|
private _dispatch;
|
|
7
7
|
private static instance;
|
|
8
8
|
private constructor();
|
|
9
|
+
isOtherAmountSelected(): boolean;
|
|
10
|
+
private syncOtherAmount;
|
|
9
11
|
static getInstance(radios?: string, other?: string): DonationAmount;
|
|
10
12
|
get amount(): number;
|
|
11
13
|
set amount(value: number);
|
|
@@ -17,12 +17,7 @@ export class DonationAmount {
|
|
|
17
17
|
this.amount = parseFloat(element.value);
|
|
18
18
|
}
|
|
19
19
|
else if (element.name == other) {
|
|
20
|
-
|
|
21
|
-
element.value =
|
|
22
|
-
cleanedAmount % 1 != 0
|
|
23
|
-
? cleanedAmount.toFixed(2)
|
|
24
|
-
: cleanedAmount.toString();
|
|
25
|
-
this.amount = cleanedAmount;
|
|
20
|
+
this.syncOtherAmount(element, true);
|
|
26
21
|
}
|
|
27
22
|
}
|
|
28
23
|
});
|
|
@@ -30,12 +25,30 @@ export class DonationAmount {
|
|
|
30
25
|
const otherField = document.querySelector(`[name='${this._other}']`);
|
|
31
26
|
if (otherField) {
|
|
32
27
|
otherField.addEventListener("keyup", (e) => {
|
|
33
|
-
this.
|
|
28
|
+
this.syncOtherAmount(otherField);
|
|
34
29
|
});
|
|
35
30
|
}
|
|
36
31
|
// Load the current amount
|
|
37
32
|
this.load();
|
|
38
33
|
}
|
|
34
|
+
// The "other" radio is the one whose value isn't a numeric amount
|
|
35
|
+
// (EN renders it as value="other"), so it cleans to 0
|
|
36
|
+
isOtherAmountSelected() {
|
|
37
|
+
const selectedAmount = document.querySelector(`input[name="${this._radios}"]:checked`);
|
|
38
|
+
return (selectedAmount !== null &&
|
|
39
|
+
ENGrid.cleanAmount(selectedAmount.value) === 0);
|
|
40
|
+
}
|
|
41
|
+
syncOtherAmount(field, formatValue = false) {
|
|
42
|
+
const otherIsSelected = this.isOtherAmountSelected();
|
|
43
|
+
const amount = ENGrid.cleanAmount(field.value);
|
|
44
|
+
if (!otherIsSelected || amount <= 0) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (formatValue) {
|
|
48
|
+
field.value = amount % 1 != 0 ? amount.toFixed(2) : amount.toString();
|
|
49
|
+
}
|
|
50
|
+
this.amount = amount;
|
|
51
|
+
}
|
|
39
52
|
static getInstance(radios = "transaction.donationAmt", other = "transaction.donationAmt.other") {
|
|
40
53
|
if (!DonationAmount.instance) {
|
|
41
54
|
DonationAmount.instance = new DonationAmount(radios, other);
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./deprecated";
|
|
|
2
2
|
export { Options, OptionsDefaults } from "./interfaces/options";
|
|
3
3
|
export { UpsellOptions, UpsellOptionsDefaults, } from "./interfaces/upsell-options";
|
|
4
4
|
export { TranslateOptions, TranslateOptionsDefaults, } from "./interfaces/translate-options";
|
|
5
|
+
export { I18nOptions, I18nDefaults } from "./interfaces/i18n-options";
|
|
5
6
|
export { ExitIntentOptions, ExitIntentOptionsDefaults, } from "./interfaces/exit-intent-options";
|
|
6
7
|
export { FrequencyUpsellOptions, FrequencyUpsellOptionsDefaults, FrequencyUpsellABTestConfig, FrequencyUpsellConfig, } from "./interfaces/frequency-upsell-options";
|
|
7
8
|
export { IframeQueueOptions, IframeQueueOptionsDefaults, IframeQueueItem, IframeQueueErrorPayload, } from "./interfaces/iframe-queue-options";
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./deprecated"; // Runs first so it can change the DOM markup befo
|
|
|
2
2
|
export { OptionsDefaults } from "./interfaces/options";
|
|
3
3
|
export { UpsellOptionsDefaults, } from "./interfaces/upsell-options";
|
|
4
4
|
export { TranslateOptionsDefaults, } from "./interfaces/translate-options";
|
|
5
|
+
export { I18nDefaults } from "./interfaces/i18n-options";
|
|
5
6
|
export { ExitIntentOptionsDefaults, } from "./interfaces/exit-intent-options";
|
|
6
7
|
export { FrequencyUpsellOptionsDefaults, } from "./interfaces/frequency-upsell-options";
|
|
7
8
|
export { IframeQueueOptionsDefaults, } from "./interfaces/iframe-queue-options";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const I18nDefaults = {
|
|
2
|
+
en: {
|
|
3
|
+
"rememberMe.label": "Remember Me",
|
|
4
|
+
"rememberMe.clearLabel": "(clear autofill)",
|
|
5
|
+
"rememberMe.tooltip": "Check “{label}” to complete forms on this device faster. While your financial information won’t be stored, you should only check this box from a personal device. Click “{clearLabel}” to remove the information from your device at any time.",
|
|
6
|
+
"rememberMe.iframeTitle": "Remember Me iframe",
|
|
7
|
+
"translateFields.state": "State",
|
|
8
|
+
"translateFields.stateGeneric": "Province / State",
|
|
9
|
+
"translateFields.stateRegion": "State/Region",
|
|
10
|
+
"translateFields.provinceTerritory": "Province / Territory",
|
|
11
|
+
"translateFields.selectState": "Select State",
|
|
12
|
+
"translateFields.select": "Select",
|
|
13
|
+
"translateFields.recipientTo": "To:",
|
|
14
|
+
"a11y.errorSummary": "There are {count} errors: {messages}.",
|
|
15
|
+
},
|
|
16
|
+
es: {
|
|
17
|
+
"rememberMe.label": "Recuérdame",
|
|
18
|
+
"rememberMe.clearLabel": "(borrar autocompletado)",
|
|
19
|
+
"rememberMe.tooltip": "Marque “{label}” para completar los formularios en este dispositivo más rápido. Aunque su información financiera no se almacenará, solo debe marcar esta casilla desde un dispositivo personal. Haga clic en “{clearLabel}” para eliminar la información de su dispositivo en cualquier momento.",
|
|
20
|
+
"rememberMe.iframeTitle": "iframe de Recuérdame",
|
|
21
|
+
"translateFields.state": "Estado",
|
|
22
|
+
"translateFields.stateGeneric": "Provincia/Estado",
|
|
23
|
+
"translateFields.stateRegion": "Estado/Región",
|
|
24
|
+
"translateFields.provinceTerritory": "Provincia/Territorio",
|
|
25
|
+
"translateFields.selectState": "Seleccione Estado",
|
|
26
|
+
"translateFields.select": "Seleccione",
|
|
27
|
+
"translateFields.recipientTo": "Para:",
|
|
28
|
+
"a11y.errorSummary": "Hay {count} errores: {messages}.",
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -30,6 +30,21 @@ const nlTranslation = [
|
|
|
30
30
|
{ field: "supporter.region", translation: "Provincie" },
|
|
31
31
|
{ field: "supporter.country", translation: "Country" },
|
|
32
32
|
];
|
|
33
|
+
// Page-language layer: keyed by lowercase 2-letter language code
|
|
34
|
+
// (see ENGrid.getPageLanguage()), applied as the base translation layer
|
|
35
|
+
// before any country-specific translations.
|
|
36
|
+
const esTranslation = [
|
|
37
|
+
{ field: "supporter.firstName", translation: "Nombre" },
|
|
38
|
+
{ field: "supporter.lastName", translation: "Apellidos" },
|
|
39
|
+
{ field: "supporter.emailAddress", translation: "Correo electrónico" },
|
|
40
|
+
{ field: "supporter.phoneNumber", translation: "Teléfono" },
|
|
41
|
+
{ field: "supporter.address1", translation: "Dirección" },
|
|
42
|
+
{ field: "supporter.address2", translation: "Departamento/Piso" },
|
|
43
|
+
{ field: "supporter.postcode", translation: "Código Postal" },
|
|
44
|
+
{ field: "supporter.city", translation: "Ciudad" },
|
|
45
|
+
{ field: "supporter.region", translation: "Provincia/Estado" },
|
|
46
|
+
{ field: "supporter.country", translation: "País" },
|
|
47
|
+
];
|
|
33
48
|
export const TranslateOptionsDefaults = {
|
|
34
49
|
BR: ptbrTranslation,
|
|
35
50
|
BRA: ptbrTranslation,
|
|
@@ -39,4 +54,5 @@ export const TranslateOptionsDefaults = {
|
|
|
39
54
|
FRA: frTranslation,
|
|
40
55
|
NL: nlTranslation,
|
|
41
56
|
NLD: nlTranslation,
|
|
57
|
+
es: esTranslation,
|
|
42
58
|
};
|
package/dist/other-amount.js
CHANGED
|
@@ -23,6 +23,11 @@ export class OtherAmount {
|
|
|
23
23
|
otherAmountField.setAttribute("autocomplete", "off");
|
|
24
24
|
otherAmountField.setAttribute("data-lpignore", "true");
|
|
25
25
|
otherAmountField.addEventListener("change", (e) => {
|
|
26
|
+
// Formatting only matters when entering a custom amount; skip
|
|
27
|
+
// unrelated change events (e.g. browser autofill firing on the
|
|
28
|
+
// field while a preset amount is selected)
|
|
29
|
+
if (!this._amount.isOtherAmountSelected())
|
|
30
|
+
return;
|
|
26
31
|
const target = e.target;
|
|
27
32
|
const amount = target.value;
|
|
28
33
|
const cleanAmount = ENGrid.cleanAmount(amount);
|
package/dist/remember-me.js
CHANGED
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import * as cookie from "./cookie";
|
|
11
11
|
import { EnForm, RememberMeEvents, DonationFrequency } from "./events";
|
|
12
|
+
import { ENGrid } from "./engrid";
|
|
12
13
|
const tippy = require("tippy.js").default;
|
|
13
14
|
// localStorage key used to cache the per-device AES-GCM encryption key.
|
|
14
15
|
// A random secret generated once per device and held in localStorage.
|
|
@@ -64,10 +65,10 @@ export class RememberMe {
|
|
|
64
65
|
: "before";
|
|
65
66
|
this.fieldClearLabel = options.fieldClearLabel
|
|
66
67
|
? options.fieldClearLabel
|
|
67
|
-
: "
|
|
68
|
+
: ENGrid.t("rememberMe.clearLabel");
|
|
68
69
|
this.rememberMeLabel = options.rememberMeLabel
|
|
69
70
|
? options.rememberMeLabel
|
|
70
|
-
: "
|
|
71
|
+
: ENGrid.t("rememberMe.label");
|
|
71
72
|
this.fieldData = {};
|
|
72
73
|
if (this.useRemote()) {
|
|
73
74
|
this.createIframe(() => {
|
|
@@ -232,11 +233,10 @@ export class RememberMe {
|
|
|
232
233
|
let rememberMeOptInField = document.getElementById("remember-me-opt-in");
|
|
233
234
|
if (!rememberMeOptInField) {
|
|
234
235
|
const rememberMeLabel = this.rememberMeLabel;
|
|
235
|
-
const rememberMeInfo =
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
`;
|
|
236
|
+
const rememberMeInfo = ENGrid.t("rememberMe.tooltip", {
|
|
237
|
+
label: rememberMeLabel,
|
|
238
|
+
clearLabel: this.fieldClearLabel,
|
|
239
|
+
});
|
|
240
240
|
const rememberMeOptInFieldChecked = this.rememberMeOptIn ? "checked" : "";
|
|
241
241
|
const rememberMeOptInField = document.createElement("div");
|
|
242
242
|
rememberMeOptInField.classList.add("en__field", "en__field--checkbox", "en__field--question", "rememberme-wrapper");
|
|
@@ -298,7 +298,7 @@ export class RememberMe {
|
|
|
298
298
|
"position:absolute;width:1px;height:1px;left:-9999px;";
|
|
299
299
|
iframe.src = this.remoteUrl;
|
|
300
300
|
iframe.setAttribute("sandbox", "allow-same-origin allow-scripts");
|
|
301
|
-
iframe.setAttribute("title", "
|
|
301
|
+
iframe.setAttribute("title", ENGrid.t("rememberMe.iframeTitle"));
|
|
302
302
|
this.iframe = iframe;
|
|
303
303
|
document.body.appendChild(this.iframe);
|
|
304
304
|
this.iframe.addEventListener("load", () => iframeLoaded(), false);
|
package/dist/translate-fields.js
CHANGED
|
@@ -12,7 +12,9 @@ export class TranslateFields {
|
|
|
12
12
|
};
|
|
13
13
|
this.countriesSelect = document.querySelectorAll('select[name="supporter.country"], select[name="transaction.shipcountry"], select[name="supporter.billingCountry"], select[name="transaction.infcountry"]');
|
|
14
14
|
let options = "EngridTranslate" in window ? window.EngridTranslate : {};
|
|
15
|
-
|
|
15
|
+
// Shallow clone: the EngridTranslate merge below concatenates arrays per
|
|
16
|
+
// key and must never mutate the shared TranslateOptionsDefaults.
|
|
17
|
+
this.options = Object.assign({}, TranslateOptionsDefaults);
|
|
16
18
|
// Don't run this for US-only forms.
|
|
17
19
|
if (document.querySelector(".en__component--formblock.us-only-form .en__field--country")) {
|
|
18
20
|
return;
|
|
@@ -50,11 +52,18 @@ export class TranslateFields {
|
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
}
|
|
55
|
+
else {
|
|
56
|
+
// No country field on the page: still translate to the page language
|
|
57
|
+
this.applyLanguageLayer();
|
|
58
|
+
}
|
|
53
59
|
}
|
|
54
60
|
translateFields(countryName = "supporter.country") {
|
|
55
61
|
this.resetTranslatedFields();
|
|
56
62
|
const countryValue = ENGrid.getFieldValue(countryName);
|
|
57
|
-
//
|
|
63
|
+
// Apply the page language as the base translation layer
|
|
64
|
+
this.applyLanguageLayer();
|
|
65
|
+
// Translate the State Field (runs last so country-specific state labels
|
|
66
|
+
// like "Provincia" or "Estado" win over the language layer)
|
|
58
67
|
this.setStateField(countryValue, this.countryToStateFields[countryName]);
|
|
59
68
|
if (countryName === "supporter.country") {
|
|
60
69
|
if (countryValue in this.options) {
|
|
@@ -66,6 +75,14 @@ export class TranslateFields {
|
|
|
66
75
|
// Translate the "To:"
|
|
67
76
|
const recipient_block = document.querySelectorAll(".recipient-block");
|
|
68
77
|
if (!!recipient_block.length) {
|
|
78
|
+
// Capture the original page-builder text once per cycle so
|
|
79
|
+
// resetTranslatedFields() can restore it — a country change never
|
|
80
|
+
// leaves a stale translation behind.
|
|
81
|
+
recipient_block.forEach((elem) => {
|
|
82
|
+
const el = elem;
|
|
83
|
+
if (!el.dataset.original)
|
|
84
|
+
el.dataset.original = el.innerHTML;
|
|
85
|
+
});
|
|
69
86
|
switch (countryValue) {
|
|
70
87
|
case "FR":
|
|
71
88
|
case "FRA":
|
|
@@ -82,10 +99,29 @@ export class TranslateFields {
|
|
|
82
99
|
case "Netherlands":
|
|
83
100
|
recipient_block.forEach((elem) => (elem.innerHTML = "Aan:"));
|
|
84
101
|
break;
|
|
102
|
+
default:
|
|
103
|
+
// No country-specific rule: use the page language string when the
|
|
104
|
+
// language dictionary defines one (e.g. "es" -> "Para:"). English
|
|
105
|
+
// pages keep the page-builder text, already restored above.
|
|
106
|
+
if (ENGrid.getPageLanguage() !== "en" &&
|
|
107
|
+
ENGrid.hasI18nKey("translateFields.recipientTo")) {
|
|
108
|
+
recipient_block.forEach((elem) => (elem.innerHTML = ENGrid.t("translateFields.recipientTo")));
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
85
111
|
}
|
|
86
112
|
}
|
|
87
113
|
}
|
|
88
114
|
}
|
|
115
|
+
// Apply the translation layer for the current page language (e.g. "es").
|
|
116
|
+
// This is the base layer; country-specific translations override it per field.
|
|
117
|
+
applyLanguageLayer() {
|
|
118
|
+
const language = ENGrid.getPageLanguage();
|
|
119
|
+
if (language in this.options) {
|
|
120
|
+
this.options[language].forEach((field) => {
|
|
121
|
+
this.translateField(field.field, field.translation);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
89
125
|
translateField(name, translation) {
|
|
90
126
|
const field = document.querySelector(`[name="${name}"]`);
|
|
91
127
|
if (field) {
|
|
@@ -153,7 +189,7 @@ export class TranslateFields {
|
|
|
153
189
|
case "GB":
|
|
154
190
|
case "GBR":
|
|
155
191
|
case "United Kingdom":
|
|
156
|
-
this.setStateValues(state, "
|
|
192
|
+
this.setStateValues(state, ENGrid.t("translateFields.stateRegion"), null);
|
|
157
193
|
break;
|
|
158
194
|
case "DE":
|
|
159
195
|
case "DEU":
|
|
@@ -167,8 +203,8 @@ export class TranslateFields {
|
|
|
167
203
|
break;
|
|
168
204
|
case "AU":
|
|
169
205
|
case "AUS":
|
|
170
|
-
this.setStateValues(state, "
|
|
171
|
-
{ label: "
|
|
206
|
+
this.setStateValues(state, ENGrid.t("translateFields.stateGeneric"), [
|
|
207
|
+
{ label: ENGrid.t("translateFields.select"), value: "" },
|
|
172
208
|
{ label: "New South Wales", value: "NSW" },
|
|
173
209
|
{ label: "Victoria", value: "VIC" },
|
|
174
210
|
{ label: "Queensland", value: "QLD" },
|
|
@@ -180,8 +216,8 @@ export class TranslateFields {
|
|
|
180
216
|
]);
|
|
181
217
|
break;
|
|
182
218
|
case "Australia":
|
|
183
|
-
this.setStateValues(state, "
|
|
184
|
-
{ label: "
|
|
219
|
+
this.setStateValues(state, ENGrid.t("translateFields.stateGeneric"), [
|
|
220
|
+
{ label: ENGrid.t("translateFields.select"), value: "" },
|
|
185
221
|
{ label: "New South Wales", value: "New South Wales" },
|
|
186
222
|
{ label: "Victoria", value: "Victoria" },
|
|
187
223
|
{ label: "Queensland", value: "Queensland" },
|
|
@@ -197,8 +233,8 @@ export class TranslateFields {
|
|
|
197
233
|
break;
|
|
198
234
|
case "US":
|
|
199
235
|
case "USA":
|
|
200
|
-
this.setStateValues(state, "
|
|
201
|
-
{ label: "
|
|
236
|
+
this.setStateValues(state, ENGrid.t("translateFields.state"), [
|
|
237
|
+
{ label: ENGrid.t("translateFields.selectState"), value: "" },
|
|
202
238
|
{ label: "Alabama", value: "AL" },
|
|
203
239
|
{ label: "Alaska", value: "AK" },
|
|
204
240
|
{ label: "Arizona", value: "AZ" },
|
|
@@ -275,8 +311,8 @@ export class TranslateFields {
|
|
|
275
311
|
]);
|
|
276
312
|
break;
|
|
277
313
|
case "United States":
|
|
278
|
-
this.setStateValues(state, "
|
|
279
|
-
{ label: "
|
|
314
|
+
this.setStateValues(state, ENGrid.t("translateFields.state"), [
|
|
315
|
+
{ label: ENGrid.t("translateFields.selectState"), value: "" },
|
|
280
316
|
{ label: "Alabama", value: "Alabama" },
|
|
281
317
|
{ label: "Alaska", value: "Alaska" },
|
|
282
318
|
{ label: "Arizona", value: "Arizona" },
|
|
@@ -363,8 +399,8 @@ export class TranslateFields {
|
|
|
363
399
|
break;
|
|
364
400
|
case "CA":
|
|
365
401
|
case "CAN":
|
|
366
|
-
this.setStateValues(state, "
|
|
367
|
-
{ label: "
|
|
402
|
+
this.setStateValues(state, ENGrid.t("translateFields.provinceTerritory"), [
|
|
403
|
+
{ label: ENGrid.t("translateFields.select"), value: "" },
|
|
368
404
|
{ label: "Alberta", value: "AB" },
|
|
369
405
|
{ label: "British Columbia", value: "BC" },
|
|
370
406
|
{ label: "Manitoba", value: "MB" },
|
|
@@ -381,8 +417,8 @@ export class TranslateFields {
|
|
|
381
417
|
]);
|
|
382
418
|
break;
|
|
383
419
|
case "Canada":
|
|
384
|
-
this.setStateValues(state, "
|
|
385
|
-
{ label: "
|
|
420
|
+
this.setStateValues(state, ENGrid.t("translateFields.provinceTerritory"), [
|
|
421
|
+
{ label: ENGrid.t("translateFields.select"), value: "" },
|
|
386
422
|
{ label: "Alberta", value: "Alberta" },
|
|
387
423
|
{ label: "British Columbia", value: "British Columbia" },
|
|
388
424
|
{ label: "Manitoba", value: "Manitoba" },
|
|
@@ -475,7 +511,7 @@ export class TranslateFields {
|
|
|
475
511
|
]);
|
|
476
512
|
break;
|
|
477
513
|
default:
|
|
478
|
-
this.setStateValues(state, "
|
|
514
|
+
this.setStateValues(state, ENGrid.t("translateFields.stateGeneric"), null);
|
|
479
515
|
break;
|
|
480
516
|
}
|
|
481
517
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AppVersion = "0.
|
|
1
|
+
export declare const AppVersion = "0.28.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AppVersion = "0.
|
|
1
|
+
export const AppVersion = "0.28.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4site/engrid-scripts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "Scripts for the ENGRID Project",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
"strongly-typed-events": "^2.0.9"
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/4site-interactive-studios/engrid#readme",
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "354dfda54591f849c4ab105d881034f7f7a2fff5",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"nodemon": "^2.0.20"
|
|
30
|
+
"nodemon": "^2.0.20",
|
|
31
|
+
"typescript": "^4.9.5"
|
|
31
32
|
}
|
|
32
33
|
}
|