@churchapps/apphelper-login 0.4.25 → 0.4.27
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/helpers/Locale.d.ts +2 -1
- package/dist/helpers/Locale.d.ts.map +1 -1
- package/dist/helpers/Locale.js +98 -77
- package/dist/helpers/Locale.js.map +1 -1
- package/package.json +57 -57
- package/src/helpers/Locale.ts +99 -83
package/dist/helpers/Locale.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export declare class Locale {
|
|
2
2
|
private static readonly supportedLanguages;
|
|
3
3
|
private static readonly extraCodes;
|
|
4
|
-
private static readonly
|
|
4
|
+
private static readonly englishFallbacks;
|
|
5
5
|
static init: (backends: string[]) => Promise<void>;
|
|
6
6
|
private static deepMerge;
|
|
7
7
|
private static isObject;
|
|
8
|
+
private static getNestedValue;
|
|
8
9
|
static t(key: string, options?: Record<string, unknown>): string;
|
|
9
10
|
static label(key: string): string;
|
|
10
11
|
static isInitialized(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Locale.d.ts","sourceRoot":"","sources":["../../src/helpers/Locale.ts"],"names":[],"mappings":"AAgBA,qBAAa,MAAM;IAClB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAaxC;IACF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAA4C;IAG9E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"Locale.d.ts","sourceRoot":"","sources":["../../src/helpers/Locale.ts"],"names":[],"mappings":"AAgBA,qBAAa,MAAM;IAClB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAaxC;IACF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAA4C;IAG9E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAqEtC;IAEF,MAAM,CAAC,IAAI,GAAU,UAAU,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAAC,CA2DrD;IAEF,OAAO,CAAC,MAAM,CAAC,SAAS;IAgBxB,OAAO,CAAC,MAAM,CAAC,QAAQ;IAKvB,OAAO,CAAC,MAAM,CAAC,cAAc;IAO7B,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;IAyChE,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAKjC,MAAM,CAAC,aAAa,IAAI,OAAO;IAK/B,MAAM,CAAC,gBAAgB,IAAI,IAAI;CAG/B"}
|
package/dist/helpers/Locale.js
CHANGED
|
@@ -19,46 +19,56 @@ export class Locale {
|
|
|
19
19
|
static isObject(obj) {
|
|
20
20
|
return obj !== null && typeof obj === "object" && !Array.isArray(obj);
|
|
21
21
|
}
|
|
22
|
-
//
|
|
22
|
+
// Helper method to get value from nested object using dot notation
|
|
23
|
+
static getNestedValue(obj, path) {
|
|
24
|
+
return path.split('.').reduce((current, key) => {
|
|
25
|
+
return current && current[key] !== undefined ? current[key] : undefined;
|
|
26
|
+
}, obj);
|
|
27
|
+
}
|
|
28
|
+
// New helper method that uses i18n with hard-coded English fallback
|
|
23
29
|
static t(key, options) {
|
|
24
30
|
try {
|
|
25
31
|
// Check if i18n is initialized and has the key
|
|
26
32
|
if (i18n && i18n.isInitialized && i18n.exists(key)) {
|
|
27
33
|
const translation = i18n.t(key, options);
|
|
28
|
-
// If translation is not
|
|
34
|
+
// If translation is not the same as the key, return it
|
|
29
35
|
if (translation !== key) {
|
|
30
36
|
return translation;
|
|
31
37
|
}
|
|
32
38
|
}
|
|
33
39
|
}
|
|
34
40
|
catch (error) {
|
|
35
|
-
|
|
41
|
+
// If i18n fails, fall through to hard-coded fallback
|
|
42
|
+
console.warn(`i18n translation failed for key "${key}":`, error);
|
|
36
43
|
}
|
|
37
|
-
//
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
// Handle simple string
|
|
41
|
-
if (
|
|
42
|
-
let result =
|
|
43
|
-
Object.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
result = result.replace('
|
|
44
|
+
// Fallback to hard-coded English translations
|
|
45
|
+
const fallbackValue = this.getNestedValue(this.englishFallbacks, key);
|
|
46
|
+
if (fallbackValue !== undefined) {
|
|
47
|
+
// Handle simple string interpolation for options
|
|
48
|
+
if (typeof fallbackValue === 'string' && options) {
|
|
49
|
+
let result = fallbackValue;
|
|
50
|
+
Object.keys(options).forEach(optionKey => {
|
|
51
|
+
const placeholder = `{{${optionKey}}}`;
|
|
52
|
+
if (result.includes(placeholder)) {
|
|
53
|
+
result = result.replace(new RegExp(placeholder, 'g'), String(options[optionKey]));
|
|
54
|
+
}
|
|
55
|
+
// Also handle {} placeholder for backward compatibility
|
|
56
|
+
if (result.includes('{}')) {
|
|
57
|
+
result = result.replace('{}', String(options[optionKey]));
|
|
47
58
|
}
|
|
48
59
|
});
|
|
49
60
|
return result;
|
|
50
61
|
}
|
|
51
|
-
return
|
|
62
|
+
return String(fallbackValue);
|
|
52
63
|
}
|
|
53
|
-
//
|
|
54
|
-
console.warn(`No translation found for key: ${key}`);
|
|
64
|
+
// If no fallback found, return the key itself
|
|
55
65
|
return key;
|
|
56
66
|
}
|
|
57
67
|
// Keep the old method for backward compatibility
|
|
58
68
|
static label(key) {
|
|
59
69
|
return this.t(key);
|
|
60
70
|
}
|
|
61
|
-
// Helper method to check if
|
|
71
|
+
// Helper method to check if i18n is initialized
|
|
62
72
|
static isInitialized() {
|
|
63
73
|
return i18n && i18n.isInitialized;
|
|
64
74
|
}
|
|
@@ -83,61 +93,76 @@ Locale.supportedLanguages = [
|
|
|
83
93
|
"zh",
|
|
84
94
|
];
|
|
85
95
|
Locale.extraCodes = { no: ["nb", "nn"] };
|
|
86
|
-
// English fallbacks for
|
|
87
|
-
Locale.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"login
|
|
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
|
-
|
|
96
|
+
// Hard-coded English fallbacks for when locale files are not available
|
|
97
|
+
Locale.englishFallbacks = {
|
|
98
|
+
"common": {
|
|
99
|
+
"pleaseWait": "Please wait...",
|
|
100
|
+
"search": "Search",
|
|
101
|
+
"cancel": "Cancel",
|
|
102
|
+
"save": "Save",
|
|
103
|
+
"delete": "Delete",
|
|
104
|
+
"edit": "Edit",
|
|
105
|
+
"add": "Add",
|
|
106
|
+
"close": "Close",
|
|
107
|
+
"date": "Date",
|
|
108
|
+
"error": "Error",
|
|
109
|
+
"submit": "Submit",
|
|
110
|
+
"update": "Update"
|
|
111
|
+
},
|
|
112
|
+
"login": {
|
|
113
|
+
"createAccount": "Create an Account",
|
|
114
|
+
"email": "Email",
|
|
115
|
+
"expiredLink": "The current link is expired.",
|
|
116
|
+
"forgot": "Forgot Password",
|
|
117
|
+
"goLogin": "Go to Login",
|
|
118
|
+
"login": "Login",
|
|
119
|
+
"password": "Password",
|
|
120
|
+
"register": "Register",
|
|
121
|
+
"registerThankYou": "Thank you for registering! Please check your email to verify your account.",
|
|
122
|
+
"requestLink": "Request a new reset link",
|
|
123
|
+
"reset": "Reset",
|
|
124
|
+
"resetInstructions": "Enter your email address to request a password reset.",
|
|
125
|
+
"resetPassword": "Reset Password",
|
|
126
|
+
"resetSent": "Password reset email sent!",
|
|
127
|
+
"setPassword": "Set Password",
|
|
128
|
+
"signIn": "Sign In",
|
|
129
|
+
"signInTitle": "Please Sign In",
|
|
130
|
+
"verifyPassword": "Verify Password",
|
|
131
|
+
"welcomeName": "Welcome back, <b>{}</b>! Please wait while we load your data.",
|
|
132
|
+
"welcomeBack": "Welcome back",
|
|
133
|
+
"validate": {
|
|
134
|
+
"email": "Please enter a valid email address.",
|
|
135
|
+
"firstName": "Please enter your first name.",
|
|
136
|
+
"invalid": "Invalid login. Please check your email or password.",
|
|
137
|
+
"lastName": "Please enter your last name.",
|
|
138
|
+
"password": "Please enter a password.",
|
|
139
|
+
"passwordLength": "Password must be at least 8 characters long.",
|
|
140
|
+
"passwordMatch": "Passwords do not match.",
|
|
141
|
+
"selectingChurch": "Error in selecting church. Please verify and try again"
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"selectChurch": {
|
|
145
|
+
"address1": "Address Line 1",
|
|
146
|
+
"address2": "Address Line 2",
|
|
147
|
+
"another": "Choose another church",
|
|
148
|
+
"city": "City",
|
|
149
|
+
"confirmRegister": "Are you sure you wish to register a new church?",
|
|
150
|
+
"country": "Country",
|
|
151
|
+
"name": "Church Name",
|
|
152
|
+
"noMatches": "No matches found.",
|
|
153
|
+
"register": "Register a New Church",
|
|
154
|
+
"selectChurch": "Select a Church",
|
|
155
|
+
"state": "State / Province",
|
|
156
|
+
"zip": "Zip / Postal Code",
|
|
157
|
+
"validate": {
|
|
158
|
+
"address": "Address cannot be blank.",
|
|
159
|
+
"city": "City cannot be blank.",
|
|
160
|
+
"country": "Country cannot be blank.",
|
|
161
|
+
"name": "Church name cannot be blank.",
|
|
162
|
+
"state": "State/Province cannot be blank.",
|
|
163
|
+
"zip": "Zip/Postal code cannot be blank."
|
|
164
|
+
}
|
|
165
|
+
}
|
|
141
166
|
};
|
|
142
167
|
Locale.init = async (backends) => {
|
|
143
168
|
const resources = {};
|
|
@@ -148,13 +173,9 @@ Locale.init = async (backends) => {
|
|
|
148
173
|
const notSupported = _a.supportedLanguages.indexOf(mappedLang) === -1;
|
|
149
174
|
langs = mappedLang === "en" || notSupported ? ["en"] : ["en", mappedLang];
|
|
150
175
|
}
|
|
151
|
-
// Initialize resources with fallbacks
|
|
152
|
-
resources["en"] = { translation: _a.fallbacks };
|
|
153
176
|
// Load translations for each language
|
|
154
177
|
for (const lang of langs) {
|
|
155
|
-
|
|
156
|
-
resources[lang] = { translation: {} };
|
|
157
|
-
}
|
|
178
|
+
resources[lang] = { translation: {} };
|
|
158
179
|
try {
|
|
159
180
|
for (const backend of backends) {
|
|
160
181
|
const url = backend.replace("{{lng}}", lang);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Locale.js","sourceRoot":"","sources":["../../src/helpers/Locale.ts"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAChE,OAAO,OAAO,MAAM,yBAAyB,CAAC;AAa9C,MAAM,OAAO,MAAM;
|
|
1
|
+
{"version":3,"file":"Locale.js","sourceRoot":"","sources":["../../src/helpers/Locale.ts"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAChE,OAAO,OAAO,MAAM,yBAAyB,CAAC;AAa9C,MAAM,OAAO,MAAM;IAsJV,MAAM,CAAC,SAAS,CACvB,MAA+B,EAC/B,MAA+B;QAE/B,KAA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,WAAW,EAC3B,IAAI,CACJ,CAAC;oBACH,CAAC;gBACF,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,OAAO,CAAC,IAAI,CAAC,oCAAoC,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC;gBACjE,CAAC;YACF,CAAC;QACF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CAAC,4CAA4C,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC;QAC1E,CAAC;IACF,CAAC;IAED,kBAAkB;IAClB,IAAI,CAAC;QACJ,MAAM,IAAI;aACR,GAAG,CAAC,OAAO,CAAC;aACZ,GAAG,CAAC,gBAAgB,CAAC;aACrB,GAAG,CAAC,gBAAgB,CAAC;aACrB,IAAI,CAAC;YACL,SAAS;YACT,WAAW,EAAE,IAAI;YACjB,KAAK,EAAE,KAAK;YACZ,aAAa,EAAE;gBACd,WAAW,EAAE,KAAK;aAClB;YACD,SAAS,EAAE;gBACV,KAAK,EAAE,CAAC,WAAW,CAAC;gBACpB,MAAM,EAAE,CAAC,cAAc,CAAC;aACxB;SACD,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,IAAI,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;IACnD,CAAC;AACF,CAAC,AA3DU,CA2DT"}
|
package/package.json
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@churchapps/apphelper-login",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "Login components for ChurchApps AppHelper",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
-
"clean": "rimraf dist",
|
|
11
|
-
"tsc": "tsc",
|
|
12
|
-
"build": "npm-run-all clean tsc"
|
|
13
|
-
},
|
|
14
|
-
"repository": {
|
|
15
|
-
"type": "git",
|
|
16
|
-
"url": "git+https://github.com/LiveChurchSolutions/AppHelper.git"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"ChurchApps",
|
|
20
|
-
"login",
|
|
21
|
-
"authentication"
|
|
22
|
-
],
|
|
23
|
-
"author": "ChurchApps.org",
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"bugs": {
|
|
26
|
-
"url": "https://github.com/LiveChurchSolutions/AppHelper/issues"
|
|
27
|
-
},
|
|
28
|
-
"homepage": "https://github.com/LiveChurchSolutions/AppHelper#readme",
|
|
29
|
-
"peerDependencies": {
|
|
30
|
-
"@churchapps/helpers": "^1.0.
|
|
31
|
-
"@churchapps/apphelper": "^0.4.
|
|
32
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
33
|
-
"react-dom": "^18.0.0 || ^19.0.0",
|
|
34
|
-
"react-router-dom": "^7.6.3"
|
|
35
|
-
},
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"@emotion/react": "^11.14.0",
|
|
38
|
-
"@emotion/styled": "^11.14.1",
|
|
39
|
-
"@mui/material": "^7.2.0",
|
|
40
|
-
"axios": "^1.10.0",
|
|
41
|
-
"i18next": "^25.3.1",
|
|
42
|
-
"jwt-decode": "^4.0.0",
|
|
43
|
-
"react-cookie": "^8.0.1",
|
|
44
|
-
"react-google-recaptcha": "^3.1.0",
|
|
45
|
-
"react-i18next": "^15.6.0",
|
|
46
|
-
"react-ga4": "^2.1.0"
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@types/node": "^24.0.10",
|
|
50
|
-
"@types/react": "^19.1.8",
|
|
51
|
-
"@types/react-dom": "^19.1.6",
|
|
52
|
-
"@types/react-google-recaptcha": "^2.1.5",
|
|
53
|
-
"npm-run-all2": "^8.0.4",
|
|
54
|
-
"rimraf": "^6.0.1",
|
|
55
|
-
"typescript": "^5.8.3"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@churchapps/apphelper-login",
|
|
3
|
+
"version": "0.4.27",
|
|
4
|
+
"description": "Login components for ChurchApps AppHelper",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
+
"clean": "rimraf dist",
|
|
11
|
+
"tsc": "tsc",
|
|
12
|
+
"build": "npm-run-all clean tsc"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/LiveChurchSolutions/AppHelper.git"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"ChurchApps",
|
|
20
|
+
"login",
|
|
21
|
+
"authentication"
|
|
22
|
+
],
|
|
23
|
+
"author": "ChurchApps.org",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/LiveChurchSolutions/AppHelper/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/LiveChurchSolutions/AppHelper#readme",
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@churchapps/helpers": "^1.0.46",
|
|
31
|
+
"@churchapps/apphelper": "^0.4.27",
|
|
32
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
33
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
34
|
+
"react-router-dom": "^7.6.3"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@emotion/react": "^11.14.0",
|
|
38
|
+
"@emotion/styled": "^11.14.1",
|
|
39
|
+
"@mui/material": "^7.2.0",
|
|
40
|
+
"axios": "^1.10.0",
|
|
41
|
+
"i18next": "^25.3.1",
|
|
42
|
+
"jwt-decode": "^4.0.0",
|
|
43
|
+
"react-cookie": "^8.0.1",
|
|
44
|
+
"react-google-recaptcha": "^3.1.0",
|
|
45
|
+
"react-i18next": "^15.6.0",
|
|
46
|
+
"react-ga4": "^2.1.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^24.0.10",
|
|
50
|
+
"@types/react": "^19.1.8",
|
|
51
|
+
"@types/react-dom": "^19.1.6",
|
|
52
|
+
"@types/react-google-recaptcha": "^2.1.5",
|
|
53
|
+
"npm-run-all2": "^8.0.4",
|
|
54
|
+
"rimraf": "^6.0.1",
|
|
55
|
+
"typescript": "^5.8.3"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/helpers/Locale.ts
CHANGED
|
@@ -31,65 +31,76 @@ export class Locale {
|
|
|
31
31
|
];
|
|
32
32
|
private static readonly extraCodes: ExtraLanguageCodes = { no: ["nb", "nn"] };
|
|
33
33
|
|
|
34
|
-
// English fallbacks for
|
|
35
|
-
private static readonly
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"login
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"selectChurch
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
34
|
+
// Hard-coded English fallbacks for when locale files are not available
|
|
35
|
+
private static readonly englishFallbacks: Record<string, any> = {
|
|
36
|
+
"common": {
|
|
37
|
+
"pleaseWait": "Please wait...",
|
|
38
|
+
"search": "Search",
|
|
39
|
+
"cancel": "Cancel",
|
|
40
|
+
"save": "Save",
|
|
41
|
+
"delete": "Delete",
|
|
42
|
+
"edit": "Edit",
|
|
43
|
+
"add": "Add",
|
|
44
|
+
"close": "Close",
|
|
45
|
+
"date": "Date",
|
|
46
|
+
"error": "Error",
|
|
47
|
+
"submit": "Submit",
|
|
48
|
+
"update": "Update"
|
|
49
|
+
},
|
|
50
|
+
"login": {
|
|
51
|
+
"createAccount": "Create an Account",
|
|
52
|
+
"email": "Email",
|
|
53
|
+
"expiredLink": "The current link is expired.",
|
|
54
|
+
"forgot": "Forgot Password",
|
|
55
|
+
"goLogin": "Go to Login",
|
|
56
|
+
"login": "Login",
|
|
57
|
+
"password": "Password",
|
|
58
|
+
"register": "Register",
|
|
59
|
+
"registerThankYou": "Thank you for registering! Please check your email to verify your account.",
|
|
60
|
+
"requestLink": "Request a new reset link",
|
|
61
|
+
"reset": "Reset",
|
|
62
|
+
"resetInstructions": "Enter your email address to request a password reset.",
|
|
63
|
+
"resetPassword": "Reset Password",
|
|
64
|
+
"resetSent": "Password reset email sent!",
|
|
65
|
+
"setPassword": "Set Password",
|
|
66
|
+
"signIn": "Sign In",
|
|
67
|
+
"signInTitle": "Please Sign In",
|
|
68
|
+
"verifyPassword": "Verify Password",
|
|
69
|
+
"welcomeName": "Welcome back, <b>{}</b>! Please wait while we load your data.",
|
|
70
|
+
"welcomeBack": "Welcome back",
|
|
71
|
+
"validate": {
|
|
72
|
+
"email": "Please enter a valid email address.",
|
|
73
|
+
"firstName": "Please enter your first name.",
|
|
74
|
+
"invalid": "Invalid login. Please check your email or password.",
|
|
75
|
+
"lastName": "Please enter your last name.",
|
|
76
|
+
"password": "Please enter a password.",
|
|
77
|
+
"passwordLength": "Password must be at least 8 characters long.",
|
|
78
|
+
"passwordMatch": "Passwords do not match.",
|
|
79
|
+
"selectingChurch": "Error in selecting church. Please verify and try again"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"selectChurch": {
|
|
83
|
+
"address1": "Address Line 1",
|
|
84
|
+
"address2": "Address Line 2",
|
|
85
|
+
"another": "Choose another church",
|
|
86
|
+
"city": "City",
|
|
87
|
+
"confirmRegister": "Are you sure you wish to register a new church?",
|
|
88
|
+
"country": "Country",
|
|
89
|
+
"name": "Church Name",
|
|
90
|
+
"noMatches": "No matches found.",
|
|
91
|
+
"register": "Register a New Church",
|
|
92
|
+
"selectChurch": "Select a Church",
|
|
93
|
+
"state": "State / Province",
|
|
94
|
+
"zip": "Zip / Postal Code",
|
|
95
|
+
"validate": {
|
|
96
|
+
"address": "Address cannot be blank.",
|
|
97
|
+
"city": "City cannot be blank.",
|
|
98
|
+
"country": "Country cannot be blank.",
|
|
99
|
+
"name": "Church name cannot be blank.",
|
|
100
|
+
"state": "State/Province cannot be blank.",
|
|
101
|
+
"zip": "Zip/Postal code cannot be blank."
|
|
102
|
+
}
|
|
103
|
+
}
|
|
93
104
|
};
|
|
94
105
|
|
|
95
106
|
static init = async (backends: string[]): Promise<void> => {
|
|
@@ -106,15 +117,9 @@ export class Locale {
|
|
|
106
117
|
langs = mappedLang === "en" || notSupported ? ["en"] : ["en", mappedLang];
|
|
107
118
|
}
|
|
108
119
|
|
|
109
|
-
// Initialize resources with fallbacks
|
|
110
|
-
resources["en"] = { translation: this.fallbacks };
|
|
111
|
-
|
|
112
120
|
// Load translations for each language
|
|
113
121
|
for (const lang of langs) {
|
|
114
|
-
|
|
115
|
-
resources[lang] = { translation: {} };
|
|
116
|
-
}
|
|
117
|
-
|
|
122
|
+
resources[lang] = { translation: {} };
|
|
118
123
|
try {
|
|
119
124
|
for (const backend of backends) {
|
|
120
125
|
const url = backend.replace("{{lng}}", lang);
|
|
@@ -179,40 +184,51 @@ export class Locale {
|
|
|
179
184
|
return obj !== null && typeof obj === "object" && !Array.isArray(obj);
|
|
180
185
|
}
|
|
181
186
|
|
|
182
|
-
//
|
|
187
|
+
// Helper method to get value from nested object using dot notation
|
|
188
|
+
private static getNestedValue(obj: Record<string, any>, path: string): any {
|
|
189
|
+
return path.split('.').reduce((current, key) => {
|
|
190
|
+
return current && current[key] !== undefined ? current[key] : undefined;
|
|
191
|
+
}, obj);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// New helper method that uses i18n with hard-coded English fallback
|
|
183
195
|
static t(key: string, options?: Record<string, unknown>): string {
|
|
184
196
|
try {
|
|
185
197
|
// Check if i18n is initialized and has the key
|
|
186
198
|
if (i18n && i18n.isInitialized && i18n.exists(key)) {
|
|
187
199
|
const translation = i18n.t(key, options);
|
|
188
|
-
// If translation is not
|
|
200
|
+
// If translation is not the same as the key, return it
|
|
189
201
|
if (translation !== key) {
|
|
190
202
|
return translation;
|
|
191
203
|
}
|
|
192
204
|
}
|
|
193
205
|
} catch (error) {
|
|
194
|
-
|
|
206
|
+
// If i18n fails, fall through to hard-coded fallback
|
|
207
|
+
console.warn(`i18n translation failed for key "${key}":`, error);
|
|
195
208
|
}
|
|
196
209
|
|
|
197
|
-
//
|
|
198
|
-
const
|
|
199
|
-
if (
|
|
200
|
-
// Handle simple string
|
|
201
|
-
if (
|
|
202
|
-
let result =
|
|
203
|
-
Object.
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
result = result.replace('
|
|
210
|
+
// Fallback to hard-coded English translations
|
|
211
|
+
const fallbackValue = this.getNestedValue(this.englishFallbacks, key);
|
|
212
|
+
if (fallbackValue !== undefined) {
|
|
213
|
+
// Handle simple string interpolation for options
|
|
214
|
+
if (typeof fallbackValue === 'string' && options) {
|
|
215
|
+
let result = fallbackValue;
|
|
216
|
+
Object.keys(options).forEach(optionKey => {
|
|
217
|
+
const placeholder = `{{${optionKey}}}`;
|
|
218
|
+
if (result.includes(placeholder)) {
|
|
219
|
+
result = result.replace(new RegExp(placeholder, 'g'), String(options[optionKey]));
|
|
220
|
+
}
|
|
221
|
+
// Also handle {} placeholder for backward compatibility
|
|
222
|
+
if (result.includes('{}')) {
|
|
223
|
+
result = result.replace('{}', String(options[optionKey]));
|
|
207
224
|
}
|
|
208
225
|
});
|
|
209
226
|
return result;
|
|
210
227
|
}
|
|
211
|
-
return
|
|
228
|
+
return String(fallbackValue);
|
|
212
229
|
}
|
|
213
230
|
|
|
214
|
-
//
|
|
215
|
-
console.warn(`No translation found for key: ${key}`);
|
|
231
|
+
// If no fallback found, return the key itself
|
|
216
232
|
return key;
|
|
217
233
|
}
|
|
218
234
|
|
|
@@ -221,7 +237,7 @@ export class Locale {
|
|
|
221
237
|
return this.t(key);
|
|
222
238
|
}
|
|
223
239
|
|
|
224
|
-
// Helper method to check if
|
|
240
|
+
// Helper method to check if i18n is initialized
|
|
225
241
|
static isInitialized(): boolean {
|
|
226
242
|
return i18n && i18n.isInitialized;
|
|
227
243
|
}
|