@churchapps/apphelper 0.2.29 → 0.2.31

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.
@@ -0,0 +1,6 @@
1
+ export declare class Locale {
2
+ private static keys;
3
+ static init: (backends: string[]) => Promise<void>;
4
+ static label(key: string): string;
5
+ }
6
+ //# sourceMappingURL=Locale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Locale.d.ts","sourceRoot":"","sources":["../../src/helpers/Locale.ts"],"names":[],"mappings":"AAQA,qBAAa,MAAM;IAEjB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAS;IAE5B,MAAM,CAAC,IAAI,aAAmB,MAAM,EAAE,mBAerC;IAED,MAAM,CAAC,KAAK,CAAC,GAAG,EAAC,MAAM;CAmDxB"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ /*
3
+ import i18n from 'i18next';
4
+ import { initReactI18next } from 'react-i18next';
5
+ import LanguageDetector from 'i18next-browser-languagedetector';
6
+ import Backend from 'i18next-chained-backend';
7
+ import HttpBackend from 'i18next-http-backend';
8
+ */
9
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
10
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11
+ return new (P || (P = Promise))(function (resolve, reject) {
12
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
14
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
15
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
16
+ });
17
+ };
18
+ var _a;
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.Locale = void 0;
21
+ class Locale {
22
+ static label(key) {
23
+ const parts = key.split(".");
24
+ let result = key;
25
+ let obj = this.keys;
26
+ for (let part of parts) {
27
+ if (obj[part]) {
28
+ obj = obj[part];
29
+ result = obj;
30
+ }
31
+ else {
32
+ return key;
33
+ }
34
+ }
35
+ return result;
36
+ }
37
+ }
38
+ exports.Locale = Locale;
39
+ _a = Locale;
40
+ Locale.keys = {};
41
+ Locale.init = (backends) => __awaiter(void 0, void 0, void 0, function* () {
42
+ const l = navigator.language.split("-")[0];
43
+ const langs = (l === "en") ? [l] : ["en", l];
44
+ console.log("LANGUAGE", navigator.language, l, langs);
45
+ let result = {};
46
+ for (let lang of langs) {
47
+ for (let backend of backends) {
48
+ let url = backend.replace("{{lng}}", lang);
49
+ console.log(url);
50
+ const data = yield fetch(url).then((response) => response.json());
51
+ result = Object.assign(Object.assign({}, result), data);
52
+ }
53
+ }
54
+ _a.keys = result;
55
+ });
56
+ //# sourceMappingURL=Locale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Locale.js","sourceRoot":"","sources":["../../src/helpers/Locale.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;;;;;;;;;;;AAEF,MAAa,MAAM;IAqBjB,MAAM,CAAC,KAAK,CAAC,GAAU;QACrB,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,MAAM,GAAG,GAAG,CAAC;QACjB,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC;QACpB,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE;YACtB,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE;gBACb,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;gBAChB,MAAM,GAAG,GAAG,CAAC;aACd;iBAAM;gBACL,OAAO,GAAG,CAAC;aACZ;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;;AAlCH,wBAwEC;;AAtEgB,WAAI,GAAO,EAAE,AAAT,CAAS;AAErB,WAAI,GAAG,CAAO,QAAiB,EAAE,EAAE;IACxC,MAAM,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAG,CAAC,CAAC,KAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3C,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IAEtD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE;QACtB,KAAK,IAAI,OAAO,IAAI,QAAQ,EAAE;YAC5B,IAAI,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAC3C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACjB,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;YAClE,MAAM,mCAAO,MAAM,GAAK,IAAI,CAAC,CAAC;SAC/B;KACF;IACD,EAAI,CAAC,IAAI,GAAG,MAAM,CAAC;AACrB,CAAC,CAAA,AAfU,CAeV"}
@@ -8,6 +8,7 @@ export { DateHelper } from "./DateHelper";
8
8
  export { ErrorHelper } from "./ErrorHelper";
9
9
  export { EventHelper } from "./EventHelper";
10
10
  export { FileHelper } from "./FileHelper";
11
+ export { Locale } from "./Locale";
11
12
  export { PersonHelper } from "./PersonHelper";
12
13
  export { SocketHelper } from "./SocketHelper";
13
14
  export { Themes } from "./Themes";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,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AW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.SlugHelper = exports.AppearanceHelper = exports.DonationHelper = exports.createEmotionCache = exports.UniqueIdHelper = exports.UserHelper = exports.Themes = exports.SocketHelper = exports.PersonHelper = exports.FileHelper = exports.EventHelper = exports.ErrorHelper = exports.DateHelper = exports.CurrencyHelper = exports.CommonEnvironmentHelper = exports.ArrayHelper = exports.ApiHelper = exports.AnalyticsHelper = void 0;
17
+ exports.SlugHelper = exports.AppearanceHelper = exports.DonationHelper = exports.createEmotionCache = exports.UniqueIdHelper = exports.UserHelper = exports.Themes = exports.SocketHelper = exports.PersonHelper = exports.Locale = exports.FileHelper = exports.EventHelper = exports.ErrorHelper = exports.DateHelper = exports.CurrencyHelper = exports.CommonEnvironmentHelper = exports.ArrayHelper = exports.ApiHelper = exports.AnalyticsHelper = void 0;
18
18
  __exportStar(require("@churchapps/helpers"), exports);
19
19
  var AnalyticsHelper_1 = require("./AnalyticsHelper");
20
20
  Object.defineProperty(exports, "AnalyticsHelper", { enumerable: true, get: function () { return AnalyticsHelper_1.AnalyticsHelper; } });
@@ -34,6 +34,8 @@ var EventHelper_1 = require("./EventHelper");
34
34
  Object.defineProperty(exports, "EventHelper", { enumerable: true, get: function () { return EventHelper_1.EventHelper; } });
35
35
  var FileHelper_1 = require("./FileHelper");
36
36
  Object.defineProperty(exports, "FileHelper", { enumerable: true, get: function () { return FileHelper_1.FileHelper; } });
37
+ var Locale_1 = require("./Locale");
38
+ Object.defineProperty(exports, "Locale", { enumerable: true, get: function () { return Locale_1.Locale; } });
37
39
  var PersonHelper_1 = require("./PersonHelper");
38
40
  Object.defineProperty(exports, "PersonHelper", { enumerable: true, get: function () { return PersonHelper_1.PersonHelper; } });
39
41
  var SocketHelper_1 = require("./SocketHelper");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA;AAChC,mDAAiD;AAAxC,gHAAA,cAAc,OAAA;AACvB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,+CAA6C;AAApC,4GAAA,YAAY,OAAA;AACrB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,mCAAiC;AAAxB,gGAAA,MAAM,OAAA;AACf,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,uDAA2E;AAA7C,oHAAA,gBAAgB,OAAA;AAC9C,2CAA0C;AAAjC,wGAAA,UAAU,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA;AAChC,mDAAiD;AAAxC,gHAAA,cAAc,OAAA;AACvB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,+CAA6C;AAApC,4GAAA,YAAY,OAAA;AACrB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,mCAAiC;AAAxB,gGAAA,MAAM,OAAA;AACf,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,uDAA2E;AAA7C,oHAAA,gBAAgB,OAAA;AAC9C,2CAA0C;AAAjC,wGAAA,UAAU,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"Login.d.ts","sourceRoot":"","sources":["../../../src/pageComponents/components/Login.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAkB,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3D,UAAU,KAAK;IAGb,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAC3B,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,CAAC,YAAY,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,aAAa,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACtC,qBAAqB,CAAC,EAAE,UAAU,CAAC;CACpC;AAED,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAsCjC,CAAA"}
1
+ {"version":3,"file":"Login.d.ts","sourceRoot":"","sources":["../../../src/pageComponents/components/Login.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAkB,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3D,UAAU,KAAK;IAGb,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAC3B,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,CAAC,YAAY,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,aAAa,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACtC,qBAAqB,CAAC,EAAE,UAAU,CAAC;CACpC;AAED,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAsCjC,CAAA"}
@@ -18,6 +18,7 @@ exports.Login = void 0;
18
18
  const react_1 = __importDefault(require("react"));
19
19
  const components_1 = require("../../components");
20
20
  const material_1 = require("@mui/material");
21
+ const Locale_1 = require("../../helpers/Locale");
21
22
  const Login = (_a) => {
22
23
  var { mainContainerCssProps = {} } = _a, props = __rest(_a, ["mainContainerCssProps"]);
23
24
  const [email, setEmail] = react_1.default.useState("");
@@ -26,11 +27,11 @@ const Login = (_a) => {
26
27
  const validate = () => {
27
28
  const result = [];
28
29
  if (!email)
29
- result.push("Please enter your email address.");
30
+ result.push(Locale_1.Locale.label("login.validate.email"));
30
31
  else if (!validateEmail(email))
31
- result.push("Please enter a valid email address.");
32
+ result.push(Locale_1.Locale.label("login.validate.email"));
32
33
  if (!password)
33
- result.push("Please enter your password.");
34
+ result.push(Locale_1.Locale.label("login.validate.password"));
34
35
  props.setErrors(result);
35
36
  return result.length === 0;
36
37
  };
@@ -39,18 +40,18 @@ const Login = (_a) => {
39
40
  props.login({ email, password });
40
41
  };
41
42
  const getRegisterLink = () => (react_1.default.createElement(react_1.default.Fragment, null,
42
- react_1.default.createElement("a", { href: "about:blank", className: "text-decoration", onClick: handleShowRegister }, "Register"),
43
+ react_1.default.createElement("a", { href: "about:blank", className: "text-decoration", onClick: handleShowRegister }, Locale_1.Locale.label("login.register")),
43
44
  " \u00A0 | \u00A0 "));
44
45
  const handleShowRegister = (e) => {
45
46
  e.preventDefault();
46
47
  props.setShowRegister(true);
47
48
  };
48
- return (react_1.default.createElement(components_1.InputBox, { headerText: "Please Sign In", saveFunction: submitLogin, saveButtonType: "submit", saveText: props.isSubmitting ? "Please wait..." : "Sign in", isSubmitting: props.isSubmitting, mainContainerCssProps: mainContainerCssProps },
49
- react_1.default.createElement(material_1.TextField, { fullWidth: true, autoFocus: true, name: "email", type: "email", label: "Email", value: email, onChange: (e) => { e.preventDefault(); setEmail(e.target.value); } }),
50
- react_1.default.createElement(material_1.TextField, { fullWidth: true, name: "email", type: "password", label: "Password", value: password, onChange: (e) => { e.preventDefault(); setPassword(e.target.value); } }),
49
+ return (react_1.default.createElement(components_1.InputBox, { headerText: Locale_1.Locale.label("login.signInTitle"), saveFunction: submitLogin, saveButtonType: "submit", saveText: props.isSubmitting ? Locale_1.Locale.label("common.pleaseWait") : Locale_1.Locale.label("login.signIn"), isSubmitting: props.isSubmitting, mainContainerCssProps: mainContainerCssProps },
50
+ react_1.default.createElement(material_1.TextField, { fullWidth: true, autoFocus: true, name: "email", type: "email", label: Locale_1.Locale.label("login.email"), value: email, onChange: (e) => { e.preventDefault(); setEmail(e.target.value); } }),
51
+ react_1.default.createElement(material_1.TextField, { fullWidth: true, name: "email", type: "password", label: Locale_1.Locale.label("login.password"), value: password, onChange: (e) => { e.preventDefault(); setPassword(e.target.value); } }),
51
52
  react_1.default.createElement(material_1.Box, { sx: { textAlign: "right", marginY: 1 } },
52
53
  getRegisterLink(),
53
- react_1.default.createElement("a", { href: "about:blank", className: "text-decoration", onClick: (e) => { e.preventDefault(); props.setShowForgot(true); } }, "Forgot Password"),
54
+ react_1.default.createElement("a", { href: "about:blank", className: "text-decoration", onClick: (e) => { e.preventDefault(); props.setShowForgot(true); } }, Locale_1.Locale.label("login.forgot")),
54
55
  "\u00A0")));
55
56
  };
56
57
  exports.Login = Login;
@@ -1 +1 @@
1
- {"version":3,"file":"Login.js","sourceRoot":"","sources":["../../../src/pageComponents/components/Login.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,iDAA4C;AAC5C,4CAA2D;AAapD,MAAM,KAAK,GAAoB,CAAC,EAAwC,EAAE,EAAE;QAA5C,EAAE,qBAAqB,GAAG,EAAE,OAAY,EAAP,KAAK,cAAtC,yBAAwC,CAAF;IAC3E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC7C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEnD,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,4CAA4C,CAAC,IAAI,CAAC,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AC,iBAAiB,EAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAG,eAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAK;qBACpJ,CACG,CACZ,CAAC;AACJ,CAAC,CAAA;AAtCY,QAAA,KAAK,SAsCjB"}
@@ -0,0 +1,22 @@
1
+ {
2
+ "common": {
3
+ "cancel": "Cancel",
4
+ "delete": "Delete",
5
+ "edit": "Edit",
6
+ "save": "Save",
7
+ "submit": "Submit",
8
+ "pleaseWait": "Please wait..."
9
+ },
10
+ "login": {
11
+ "email": "Email",
12
+ "password": "Password",
13
+ "forgot": "Forgot Password",
14
+ "signInTitle": "Please Sign In",
15
+ "signIn": "Sign In",
16
+ "register": "Register",
17
+ "validate": {
18
+ "email": "Please enter a valid email address.",
19
+ "password": "Please enter a password."
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "common": {
3
+ "cancel": "Cancelar",
4
+ "delete": "Eliminar",
5
+ "edit": "Editar",
6
+ "save": "Guardar",
7
+ "submit": "Enviar",
8
+ "pleaseWait": "Por favor, espere..."
9
+ },
10
+ "login": {
11
+ "email": "Correo electrónico",
12
+ "password": "Contraseña",
13
+ "forgot": "Olvidé la contraseña",
14
+ "signInTitle": "Por favor, inicie sesión",
15
+ "signIn": "Iniciar sesión",
16
+ "register": "Registrarse",
17
+ "validate": {
18
+ "email": "Por favor, introduzca una dirección de correo electrónico válida.",
19
+ "password": "Por favor, introduzca una contraseña."
20
+ }
21
+ }
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@churchapps/apphelper",
3
- "version": "0.2.29",
3
+ "version": "0.2.31",
4
4
  "description": "Library of helper functions for React and NextJS ChurchApps",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -9,7 +9,8 @@
9
9
  "copy-css": "copyfiles -f src/components/markdownEditor/editor.css dist/components/markdownEditor",
10
10
  "copy-icons": "copyfiles -f src/components/markdownEditor/images/icons/* dist/components/markdownEditor/images/icons",
11
11
  "copy-emojis": "copyfiles -f src/components/markdownEditor/images/emoji/* dist/components/markdownEditor/images/emoji",
12
- "copy-assets": "npm-run-all copy-css copy-icons copy-emojis",
12
+ "copy-languages": "copyfiles -a public/** dist",
13
+ "copy-assets": "npm-run-all copy-css copy-icons copy-emojis copy-languages",
13
14
  "link": "link",
14
15
  "tsc": "tsc",
15
16
  "build": "npm-run-all clean tsc copy-assets",
@@ -34,7 +35,7 @@
34
35
  "react-router-dom": "^6.15.0"
35
36
  },
36
37
  "dependencies": {
37
- "@churchapps/helpers": "^1.0.21",
38
+ "@churchapps/helpers": "^1.0.22",
38
39
  "@emotion/cache": "^11.11.0",
39
40
  "@emotion/react": "^11.11.1",
40
41
  "@emotion/styled": "^11.11.0",
@@ -0,0 +1,22 @@
1
+ {
2
+ "common": {
3
+ "cancel": "Cancel",
4
+ "delete": "Delete",
5
+ "edit": "Edit",
6
+ "save": "Save",
7
+ "submit": "Submit",
8
+ "pleaseWait": "Please wait..."
9
+ },
10
+ "login": {
11
+ "email": "Email",
12
+ "password": "Password",
13
+ "forgot": "Forgot Password",
14
+ "signInTitle": "Please Sign In",
15
+ "signIn": "Sign In",
16
+ "register": "Register",
17
+ "validate": {
18
+ "email": "Please enter a valid email address.",
19
+ "password": "Please enter a password."
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "common": {
3
+ "cancel": "Cancelar",
4
+ "delete": "Eliminar",
5
+ "edit": "Editar",
6
+ "save": "Guardar",
7
+ "submit": "Enviar",
8
+ "pleaseWait": "Por favor, espere..."
9
+ },
10
+ "login": {
11
+ "email": "Correo electrónico",
12
+ "password": "Contraseña",
13
+ "forgot": "Olvidé la contraseña",
14
+ "signInTitle": "Por favor, inicie sesión",
15
+ "signIn": "Iniciar sesión",
16
+ "register": "Registrarse",
17
+ "validate": {
18
+ "email": "Por favor, introduzca una dirección de correo electrónico válida.",
19
+ "password": "Por favor, introduzca una contraseña."
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,81 @@
1
+ /*
2
+ import i18n from 'i18next';
3
+ import { initReactI18next } from 'react-i18next';
4
+ import LanguageDetector from 'i18next-browser-languagedetector';
5
+ import Backend from 'i18next-chained-backend';
6
+ import HttpBackend from 'i18next-http-backend';
7
+ */
8
+
9
+ export class Locale {
10
+
11
+ private static keys:any = {}
12
+
13
+ static init = async (backends:string[]) => {
14
+ const l = navigator.language.split("-")[0];
15
+ const langs = (l==="en") ? [l] : ["en", l];
16
+ console.log("LANGUAGE", navigator.language, l, langs);
17
+
18
+ let result = {};
19
+ for (let lang of langs) {
20
+ for (let backend of backends) {
21
+ let url = backend.replace("{{lng}}", lang);
22
+ console.log(url);
23
+ const data = await fetch(url).then((response) => response.json());
24
+ result = {...result, ...data};
25
+ }
26
+ }
27
+ this.keys = result;
28
+ }
29
+
30
+ static label(key:string) {
31
+ const parts = key.split(".");
32
+ let result = key;
33
+ let obj = this.keys;
34
+ for (let part of parts) {
35
+ if (obj[part]) {
36
+ obj = obj[part];
37
+ result = obj;
38
+ } else {
39
+ return key;
40
+ }
41
+ }
42
+ return result;
43
+ }
44
+
45
+ /*
46
+ //'/locales/{{lng}}.json'
47
+ static init = async (backends:string[]) => {
48
+
49
+ const backendOptions = backends.map((path) => ({ loadPath: path }));
50
+
51
+
52
+ console.log("backend options", backendOptions)
53
+ console.log({backend: {
54
+ backends: backends.map(() => HttpBackend),
55
+ backendOptions,
56
+ }})
57
+
58
+ await i18n
59
+ .use(Backend)
60
+ .use(LanguageDetector)
61
+ .use(initReactI18next)
62
+ .init({
63
+ fallbackLng: 'en',
64
+ debug: true,
65
+ interpolation: {
66
+ escapeValue: false, // React already does escaping
67
+ },
68
+ backend: {
69
+ backends: backends.map(() => HttpBackend),
70
+ backendOptions,
71
+ },
72
+ supportedLngs: ['en', 'es'],
73
+ });
74
+ }
75
+
76
+ static label(key:string) {
77
+ return i18n.t(key);
78
+ }
79
+ */
80
+
81
+ }
@@ -8,6 +8,7 @@ export { DateHelper } from "./DateHelper";
8
8
  export { ErrorHelper } from "./ErrorHelper";
9
9
  export { EventHelper } from "./EventHelper";
10
10
  export { FileHelper } from "./FileHelper";
11
+ export { Locale } from "./Locale";
11
12
  export { PersonHelper } from "./PersonHelper"
12
13
  export { SocketHelper } from "./SocketHelper";
13
14
  export { Themes } from "./Themes"
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { InputBox } from "../../components";
3
3
  import { TextField, Box, PaperProps } from "@mui/material";
4
+ import { Locale } from "../../helpers/Locale";
4
5
 
5
6
  interface Props {
6
7
  //registerCallback: () => void,
@@ -21,9 +22,9 @@ export const Login: React.FC<Props> = ({ mainContainerCssProps = {}, ...props })
21
22
 
22
23
  const validate = () => {
23
24
  const result = [];
24
- if (!email) result.push("Please enter your email address.");
25
- else if (!validateEmail(email)) result.push("Please enter a valid email address.");
26
- if (!password) result.push("Please enter your password.");
25
+ if (!email) result.push(Locale.label("login.validate.email"));
26
+ else if (!validateEmail(email)) result.push(Locale.label("login.validate.email"));
27
+ if (!password) result.push(Locale.label("login.validate.password"));
27
28
  props.setErrors(result);
28
29
  return result.length === 0;
29
30
  }
@@ -33,7 +34,7 @@ export const Login: React.FC<Props> = ({ mainContainerCssProps = {}, ...props })
33
34
  }
34
35
 
35
36
  const getRegisterLink = () => (
36
- <><a href="about:blank" className="text-decoration" onClick={handleShowRegister}>Register</a> &nbsp; | &nbsp; </>
37
+ <><a href="about:blank" className="text-decoration" onClick={handleShowRegister}>{Locale.label("login.register")}</a> &nbsp; | &nbsp; </>
37
38
  )
38
39
 
39
40
  const handleShowRegister = (e: React.MouseEvent) => {
@@ -42,12 +43,12 @@ export const Login: React.FC<Props> = ({ mainContainerCssProps = {}, ...props })
42
43
  }
43
44
 
44
45
  return (
45
- <InputBox headerText="Please Sign In" saveFunction={submitLogin} saveButtonType="submit" saveText={props.isSubmitting ? "Please wait..." : "Sign in"} isSubmitting={props.isSubmitting} mainContainerCssProps={mainContainerCssProps}>
46
- <TextField fullWidth autoFocus name="email" type="email" label="Email" value={email} onChange={(e) => { e.preventDefault(); setEmail(e.target.value) }} />
47
- <TextField fullWidth name="email" type="password" label="Password" value={password} onChange={(e) => { e.preventDefault(); setPassword(e.target.value) }} />
46
+ <InputBox headerText={Locale.label("login.signInTitle")} saveFunction={submitLogin} saveButtonType="submit" saveText={props.isSubmitting ? Locale.label("common.pleaseWait") : Locale.label("login.signIn")} isSubmitting={props.isSubmitting} mainContainerCssProps={mainContainerCssProps}>
47
+ <TextField fullWidth autoFocus name="email" type="email" label={Locale.label("login.email")} value={email} onChange={(e) => { e.preventDefault(); setEmail(e.target.value) }} />
48
+ <TextField fullWidth name="email" type="password" label={Locale.label("login.password")} value={password} onChange={(e) => { e.preventDefault(); setPassword(e.target.value) }} />
48
49
  <Box sx={{ textAlign: "right", marginY: 1 }}>
49
50
  {getRegisterLink()}
50
- <a href="about:blank" className="text-decoration" onClick={(e) => { e.preventDefault(); props.setShowForgot(true); }}>Forgot Password</a>&nbsp;
51
+ <a href="about:blank" className="text-decoration" onClick={(e) => { e.preventDefault(); props.setShowForgot(true); }}>{Locale.label("login.forgot")}</a>&nbsp;
51
52
  </Box>
52
53
  </InputBox>
53
54
  );