@evlop/commons 1.0.236 → 1.0.237
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/helpers/handlebarHelpers.js +1 -1
- package/dist/src/helpers/handlebarHelpers.js.map +1 -1
- package/dist/src/helpers/handlebarHelpers.test.d.ts.map +1 -1
- package/dist/src/helpers/handlebarHelpers.test.js +1 -1
- package/dist/src/helpers/handlebarHelpers.test.js.map +1 -1
- package/dist/src/hooks/useTranslation.js +2 -5
- package/dist/src/hooks/useTranslation.js.map +1 -1
- package/dist/src/providers/I18nProvider.js +11 -14
- package/dist/src/providers/I18nProvider.js.map +1 -1
- package/package.json +1 -1
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const handlebars_min_js_1 = __importDefault(require("handlebars/dist/handlebars.min.js"));
|
7
7
|
const moment_1 = __importDefault(require("moment"));
|
8
8
|
const lodash_1 = require("lodash");
|
9
|
-
const i18ninstance_1 = __importDefault(require("
|
9
|
+
const i18ninstance_1 = __importDefault(require("./i18ninstance"));
|
10
10
|
handlebars_min_js_1.default.registerHelper('json', function (context) {
|
11
11
|
return JSON.stringify(context, null, 2);
|
12
12
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"handlebarHelpers.js","sourceRoot":"","sources":["../../../src/helpers/handlebarHelpers.ts"],"names":[],"mappings":";;;;;AAAA,0FAA2D;AAC3D,oDAA4B;AAC5B,mCAA+B;AAC/B,
|
1
|
+
{"version":3,"file":"handlebarHelpers.js","sourceRoot":"","sources":["../../../src/helpers/handlebarHelpers.ts"],"names":[],"mappings":";;;;;AAAA,0FAA2D;AAC3D,oDAA4B;AAC5B,mCAA+B;AAC/B,kEAA0C;AAE1C,2BAAU,CAAC,cAAc,CAAC,MAAM,EAAE,UAAS,OAAO;IAC9C,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC5C,CAAC,CAAC,CAAC;AAEH,2BAAU,CAAC,cAAc,CAAC,MA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.test.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"handlebarHelpers.test.d.ts","sourceRoot":"","sources":["../../../src/helpers/handlebarHelpers.test.ts"],"names":[],"mappings":"AAGA,OAAO,oBAAoB,CAAC"}
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const chai_1 = require("chai");
|
7
7
|
const handlebars_min_js_1 = __importDefault(require("handlebars/dist/handlebars.min.js"));
|
8
8
|
const moment_1 = __importDefault(require("moment"));
|
9
|
-
const i18ninstance_1 = __importDefault(require("../constants/i18ninstance"));
|
10
9
|
require("./handlebarHelpers");
|
10
|
+
const i18ninstance_1 = __importDefault(require("./i18ninstance"));
|
11
11
|
describe('Test handlebar temaplates', function () {
|
12
12
|
it('scan returns last value if none available before that', () => {
|
13
13
|
const stringValue = "{{scan a b c}}";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"handlebarHelpers.test.js","sourceRoot":"","sources":["../../../src/helpers/handlebarHelpers.test.ts"],"names":[],"mappings":";;;;;AAAA,+BAA4B;AAC5B,0FAA2D;AAC3D,oDAA4B;AAC5B,
|
1
|
+
{"version":3,"file":"handlebarHelpers.test.js","sourceRoot":"","sources":["../../../src/helpers/handlebarHelpers.test.ts"],"names":[],"mappings":";;;;;AAAA,+BAA4B;AAC5B,0FAA2D;AAC3D,oDAA4B;AAC5B,8BAA4B;AAC5B,kEAA0C;AAE1C,QAAQ,CAAC,2BAA2B,EAAE;IAClC,EAAE,CAAC,wDAAwD,EAAE,GAAE,EAAE;QAC7D,MAAM,WAAW,GAAG,gBAAgB,CAAC;QACrC,MAAM,QAAQ,GAAG,2BAAU,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACjD,MAAM,eAAe,GAAG,QAAQ,CAAC,EAAC,CAAC,EAAE,KAAK,EAAC,CAAC,CAAC;QAE7C,aAAM,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IACz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|| function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
3
|
exports.useTranslation = void 0;
|
7
4
|
const react_1 = require("react");
|
8
|
-
const i18ninstance_1 = __importDefault(require("../constants/i18ninstance"));
|
9
5
|
const useScope_1 = require("./useScope");
|
6
|
+
const helpers_1 = require("../helpers");
|
10
7
|
const useTranslation = () => {
|
11
8
|
const i18n = useScope_1.useScope('i18n');
|
12
9
|
const translate = react_1.useCallback((key, options) => {
|
13
|
-
return
|
10
|
+
return helpers_1.i18nInstance.t(key, options);
|
14
11
|
}, [i18n]);
|
15
12
|
return translate;
|
16
13
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTranslation.js","sourceRoot":"","sources":["../../../src/hooks/useTranslation.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"useTranslation.js","sourceRoot":"","sources":["../../../src/hooks/useTranslation.tsx"],"names":[],"mappings":";;;AACA,iCAAoC;AACpC,yCAAsC;AACtC,wCAA0C;AAEnC,MAAM,cAAc,GAAG,GAAE,EAAE;IAC9B,MAAM,IAAI,GAAG,mBAAQ,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,SAAS,GAAc,mBAAW,CAAC,CAAC,GAAQ,EAAE,OAAa,EAAC,EAAE;QAChE,OAAO,sBAAY,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACvC,CAAC,EAAG,CAAC,IAAI,CAAC,CAAC,CAAA;IAEX,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAPW,QAAA,cAAc,kBAOzB;AAEF,kBAAe,sBAAc,CAAC"}
|
@@ -18,18 +18,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
18
|
__setModuleDefault(result, mod);
|
19
19
|
return result;
|
20
20
|
};
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
23
|
-
};
|
24
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
25
22
|
exports.I18nProvider = void 0;
|
26
23
|
const lodash_1 = require("lodash");
|
27
24
|
const react_1 = __importStar(require("react"));
|
28
25
|
const react_redux_1 = require("react-redux");
|
29
|
-
const i18ninstance_1 = __importDefault(require("../constants/i18ninstance"));
|
30
26
|
const useConfig_1 = require("../hooks/useConfig");
|
31
27
|
const reducers_1 = require("../reducers");
|
32
28
|
const Scope_1 = require("./Scope");
|
29
|
+
const helpers_1 = require("../helpers");
|
33
30
|
const I18nProvider = ({ children }) => {
|
34
31
|
const dispatch = react_redux_1.useDispatch();
|
35
32
|
const i18nResources = useConfig_1.useConfig('i18n');
|
@@ -37,32 +34,32 @@ const I18nProvider = ({ children }) => {
|
|
37
34
|
const language = react_redux_1.useSelector(s => s.session.data.language);
|
38
35
|
const setLanguage = react_1.useCallback((lng) => dispatch(reducers_1.setSessionValue('language', lng)), [dispatch]);
|
39
36
|
react_1.useEffect(() => {
|
40
|
-
if (language ===
|
37
|
+
if (language === helpers_1.i18nInstance.language)
|
41
38
|
return;
|
42
39
|
if (language) {
|
43
|
-
|
40
|
+
helpers_1.i18nInstance.changeLanguage(language);
|
44
41
|
}
|
45
42
|
else {
|
46
|
-
setLanguage(
|
43
|
+
setLanguage(helpers_1.i18nInstance.language);
|
47
44
|
}
|
48
45
|
}, [language]);
|
49
46
|
react_1.useEffect(() => {
|
50
47
|
const languageChangeHandeller = (lng) => setLanguage(lng);
|
51
|
-
|
52
|
-
return () =>
|
48
|
+
helpers_1.i18nInstance.on("languageChanged", languageChangeHandeller);
|
49
|
+
return () => helpers_1.i18nInstance.off("languageChanged", languageChangeHandeller);
|
53
50
|
}, [setLanguage]);
|
54
51
|
const updatei18nResourceVersion = react_1.useCallback(lodash_1.debounce(() => setVersion(Date.now()), 250), []);
|
55
52
|
react_1.useEffect(() => {
|
56
53
|
const resourceChangeHandeller = () => updatei18nResourceVersion();
|
57
|
-
|
58
|
-
|
54
|
+
helpers_1.i18nInstance.on("added", resourceChangeHandeller);
|
55
|
+
helpers_1.i18nInstance.on("removed", resourceChangeHandeller);
|
59
56
|
return () => {
|
60
|
-
|
61
|
-
|
57
|
+
helpers_1.i18nInstance.off("added", resourceChangeHandeller);
|
58
|
+
helpers_1.i18nInstance.off("removed", resourceChangeHandeller);
|
62
59
|
};
|
63
60
|
}, [updatei18nResourceVersion]);
|
64
61
|
react_1.useEffect(() => {
|
65
|
-
lodash_1.forEach(i18nResources, (values, language) =>
|
62
|
+
lodash_1.forEach(i18nResources, (values, language) => helpers_1.i18nInstance.addResources(language, 'common', values));
|
66
63
|
updatei18nResourceVersion();
|
67
64
|
}, [i18nResources, updatei18nResourceVersion]);
|
68
65
|
const i18nScope = react_1.useMemo(() => ({ v: version, language }), [version, language]);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"I18nProvider.js","sourceRoot":"","sources":["../../../src/providers/I18nProvider.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"I18nProvider.js","sourceRoot":"","sources":["../../../src/providers/I18nProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAyC;AACzC,+CAAuE;AACvE,6CAAqD;AACrD,kDAA+C;AAC/C,0CAA8C;AAC9C,mCAAwC;AACxC,wCAA0C;AAMnC,MAAM,YAAY,GAAgC,CAAC,EAAC,QAAQ,EAAC,EAAE,EAAE;IACtE,MAAM,QAAQ,GAAG,yBAAW,EAAE,CAAC;IAC/B,MAAM,aAAa,GAAG,qBAAS,CAAC,MAAM,CAAC,CAAC;IAExC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,gBAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAEnD,MAAM,QAAQ,GAAG,yBAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC1D,MAAM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