@esfaenza/localizations 11.2.9 → 11.2.11
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/bundles/esfaenza-localizations.umd.js +622 -182
- package/bundles/esfaenza-localizations.umd.js.map +1 -1
- package/bundles/esfaenza-localizations.umd.min.js +15 -1
- package/bundles/esfaenza-localizations.umd.min.js.map +1 -1
- package/esfaenza-localizations.d.ts +2 -1
- package/esfaenza-localizations.metadata.json +1 -1
- package/esm2015/esfaenza-localizations.js +3 -2
- package/esm2015/lib/core/localization.base.js +82 -158
- package/esm2015/lib/core/localization.persistor.js +103 -0
- package/esm2015/lib/locale-persistor/LocalStorageCachePersistor.js +22 -0
- package/esm2015/lib/locale-persistor/LocalePersistor.js +8 -0
- package/esm2015/lib/localizations.module.js +12 -4
- package/esm2015/lib/localizations.service.js +54 -34
- package/esm2015/lib/models/BaseLocalizationTokens.js +14 -0
- package/esm2015/lib/models/ItemLocalization.js +18 -0
- package/esm2015/lib/models/LocaleDefinitions.js +32 -0
- package/esm2015/lib/models/LocaleObject.js +18 -0
- package/esm2015/lib/models/LocalizationMissingPolicy.js +11 -0
- package/esm2015/lib/models/LocalizationModuleConfig.js +6 -0
- package/esm2015/lib/models/SpecializedLocalization.js +16 -0
- package/esm2015/lib/tokens.js +4 -4
- package/esm2015/public-api.js +5 -2
- package/fesm2015/esfaenza-localizations.js +260 -172
- package/fesm2015/esfaenza-localizations.js.map +1 -1
- package/lib/core/localization.base.d.ts +12 -59
- package/lib/core/localization.persistor.d.ts +57 -0
- package/lib/locale-persistor/LocalStorageCachePersistor.d.ts +8 -0
- package/lib/locale-persistor/LocalePersistor.d.ts +18 -0
- package/lib/localizations.module.d.ts +1 -1
- package/lib/localizations.service.d.ts +11 -17
- package/lib/models/BaseLocalizationTokens.d.ts +12 -0
- package/lib/models/LocalizationMissingPolicy.d.ts +9 -0
- package/lib/models/LocalizationModuleConfig.d.ts +17 -0
- package/lib/tokens.d.ts +4 -3
- package/package.json +1 -1
- package/public-api.d.ts +4 -1
- package/esm2015/lib/models/classes/ItemLocalization.js +0 -18
- package/esm2015/lib/models/classes/LocaleDefinitions.js +0 -32
- package/esm2015/lib/models/classes/LocaleObject.js +0 -18
- package/esm2015/lib/models/classes/LocalizationModuleConfig.js +0 -6
- package/esm2015/lib/models/classes/SpecializedLocalization.js +0 -16
- package/esm2015/lib/models/index.js +0 -6
- package/lib/models/classes/LocalizationModuleConfig.d.ts +0 -9
- package/lib/models/index.d.ts +0 -5
- /package/lib/models/{classes/ItemLocalization.d.ts → ItemLocalization.d.ts} +0 -0
- /package/lib/models/{classes/LocaleDefinitions.d.ts → LocaleDefinitions.d.ts} +0 -0
- /package/lib/models/{classes/LocaleObject.d.ts → LocaleObject.d.ts} +0 -0
- /package/lib/models/{classes/SpecializedLocalization.d.ts → SpecializedLocalization.d.ts} +0 -0
|
@@ -1,13 +1,339 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@esfaenza/extensions')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@esfaenza/localizations', ['exports', '@angular/core', '@esfaenza/extensions'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.esfaenza = global.esfaenza || {}, global.esfaenza.localizations = {}), global.ng.core, global.extensions));
|
|
5
|
-
}(this, (function (exports,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs/operators'), require('rxjs'), require('@esfaenza/extensions')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@esfaenza/localizations', ['exports', '@angular/core', 'rxjs/operators', 'rxjs', '@esfaenza/extensions'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.esfaenza = global.esfaenza || {}, global.esfaenza.localizations = {}), global.ng.core, global.rxjs.operators, global.rxjs, global.extensions));
|
|
5
|
+
}(this, (function (exports, i0, operators, rxjs, extensions) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return e[k];
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n['default'] = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
28
|
+
|
|
29
|
+
/*! *****************************************************************************
|
|
30
|
+
Copyright (c) Microsoft Corporation.
|
|
31
|
+
|
|
32
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
33
|
+
purpose with or without fee is hereby granted.
|
|
34
|
+
|
|
35
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
36
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
37
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
38
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
39
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
40
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
41
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
42
|
+
***************************************************************************** */
|
|
43
|
+
/* global Reflect, Promise */
|
|
44
|
+
var extendStatics = function (d, b) {
|
|
45
|
+
extendStatics = Object.setPrototypeOf ||
|
|
46
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
47
|
+
function (d, b) { for (var p in b)
|
|
48
|
+
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
49
|
+
d[p] = b[p]; };
|
|
50
|
+
return extendStatics(d, b);
|
|
51
|
+
};
|
|
52
|
+
function __extends(d, b) {
|
|
53
|
+
if (typeof b !== "function" && b !== null)
|
|
54
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
55
|
+
extendStatics(d, b);
|
|
56
|
+
function __() { this.constructor = d; }
|
|
57
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
58
|
+
}
|
|
59
|
+
var __assign = function () {
|
|
60
|
+
__assign = Object.assign || function __assign(t) {
|
|
61
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
62
|
+
s = arguments[i];
|
|
63
|
+
for (var p in s)
|
|
64
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
65
|
+
t[p] = s[p];
|
|
66
|
+
}
|
|
67
|
+
return t;
|
|
68
|
+
};
|
|
69
|
+
return __assign.apply(this, arguments);
|
|
70
|
+
};
|
|
71
|
+
function __rest(s, e) {
|
|
72
|
+
var t = {};
|
|
73
|
+
for (var p in s)
|
|
74
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
75
|
+
t[p] = s[p];
|
|
76
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
77
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
78
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
79
|
+
t[p[i]] = s[p[i]];
|
|
80
|
+
}
|
|
81
|
+
return t;
|
|
82
|
+
}
|
|
83
|
+
function __decorate(decorators, target, key, desc) {
|
|
84
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
85
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
86
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
87
|
+
else
|
|
88
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
89
|
+
if (d = decorators[i])
|
|
90
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
91
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
92
|
+
}
|
|
93
|
+
function __param(paramIndex, decorator) {
|
|
94
|
+
return function (target, key) { decorator(target, key, paramIndex); };
|
|
95
|
+
}
|
|
96
|
+
function __metadata(metadataKey, metadataValue) {
|
|
97
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
98
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
99
|
+
}
|
|
100
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
101
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
102
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
103
|
+
function fulfilled(value) { try {
|
|
104
|
+
step(generator.next(value));
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
reject(e);
|
|
108
|
+
} }
|
|
109
|
+
function rejected(value) { try {
|
|
110
|
+
step(generator["throw"](value));
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
reject(e);
|
|
114
|
+
} }
|
|
115
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
116
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function __generator(thisArg, body) {
|
|
120
|
+
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
121
|
+
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
122
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
123
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
124
|
+
function step(op) {
|
|
125
|
+
if (f)
|
|
126
|
+
throw new TypeError("Generator is already executing.");
|
|
127
|
+
while (_)
|
|
128
|
+
try {
|
|
129
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
130
|
+
return t;
|
|
131
|
+
if (y = 0, t)
|
|
132
|
+
op = [op[0] & 2, t.value];
|
|
133
|
+
switch (op[0]) {
|
|
134
|
+
case 0:
|
|
135
|
+
case 1:
|
|
136
|
+
t = op;
|
|
137
|
+
break;
|
|
138
|
+
case 4:
|
|
139
|
+
_.label++;
|
|
140
|
+
return { value: op[1], done: false };
|
|
141
|
+
case 5:
|
|
142
|
+
_.label++;
|
|
143
|
+
y = op[1];
|
|
144
|
+
op = [0];
|
|
145
|
+
continue;
|
|
146
|
+
case 7:
|
|
147
|
+
op = _.ops.pop();
|
|
148
|
+
_.trys.pop();
|
|
149
|
+
continue;
|
|
150
|
+
default:
|
|
151
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
152
|
+
_ = 0;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
156
|
+
_.label = op[1];
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
160
|
+
_.label = t[1];
|
|
161
|
+
t = op;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
if (t && _.label < t[2]) {
|
|
165
|
+
_.label = t[2];
|
|
166
|
+
_.ops.push(op);
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
if (t[2])
|
|
170
|
+
_.ops.pop();
|
|
171
|
+
_.trys.pop();
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
op = body.call(thisArg, _);
|
|
175
|
+
}
|
|
176
|
+
catch (e) {
|
|
177
|
+
op = [6, e];
|
|
178
|
+
y = 0;
|
|
179
|
+
}
|
|
180
|
+
finally {
|
|
181
|
+
f = t = 0;
|
|
182
|
+
}
|
|
183
|
+
if (op[0] & 5)
|
|
184
|
+
throw op[1];
|
|
185
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
189
|
+
if (k2 === undefined)
|
|
190
|
+
k2 = k;
|
|
191
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
|
192
|
+
}) : (function (o, m, k, k2) {
|
|
193
|
+
if (k2 === undefined)
|
|
194
|
+
k2 = k;
|
|
195
|
+
o[k2] = m[k];
|
|
196
|
+
});
|
|
197
|
+
function __exportStar(m, o) {
|
|
198
|
+
for (var p in m)
|
|
199
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
200
|
+
__createBinding(o, m, p);
|
|
201
|
+
}
|
|
202
|
+
function __values(o) {
|
|
203
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
204
|
+
if (m)
|
|
205
|
+
return m.call(o);
|
|
206
|
+
if (o && typeof o.length === "number")
|
|
207
|
+
return {
|
|
208
|
+
next: function () {
|
|
209
|
+
if (o && i >= o.length)
|
|
210
|
+
o = void 0;
|
|
211
|
+
return { value: o && o[i++], done: !o };
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
215
|
+
}
|
|
216
|
+
function __read(o, n) {
|
|
217
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
218
|
+
if (!m)
|
|
219
|
+
return o;
|
|
220
|
+
var i = m.call(o), r, ar = [], e;
|
|
221
|
+
try {
|
|
222
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
223
|
+
ar.push(r.value);
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
e = { error: error };
|
|
227
|
+
}
|
|
228
|
+
finally {
|
|
229
|
+
try {
|
|
230
|
+
if (r && !r.done && (m = i["return"]))
|
|
231
|
+
m.call(i);
|
|
232
|
+
}
|
|
233
|
+
finally {
|
|
234
|
+
if (e)
|
|
235
|
+
throw e.error;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return ar;
|
|
239
|
+
}
|
|
240
|
+
/** @deprecated */
|
|
241
|
+
function __spread() {
|
|
242
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
243
|
+
ar = ar.concat(__read(arguments[i]));
|
|
244
|
+
return ar;
|
|
245
|
+
}
|
|
246
|
+
/** @deprecated */
|
|
247
|
+
function __spreadArrays() {
|
|
248
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
249
|
+
s += arguments[i].length;
|
|
250
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
251
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
252
|
+
r[k] = a[j];
|
|
253
|
+
return r;
|
|
254
|
+
}
|
|
255
|
+
function __spreadArray(to, from) {
|
|
256
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
257
|
+
to[j] = from[i];
|
|
258
|
+
return to;
|
|
259
|
+
}
|
|
260
|
+
function __await(v) {
|
|
261
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
262
|
+
}
|
|
263
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
264
|
+
if (!Symbol.asyncIterator)
|
|
265
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
266
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
267
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
268
|
+
function verb(n) { if (g[n])
|
|
269
|
+
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
270
|
+
function resume(n, v) { try {
|
|
271
|
+
step(g[n](v));
|
|
272
|
+
}
|
|
273
|
+
catch (e) {
|
|
274
|
+
settle(q[0][3], e);
|
|
275
|
+
} }
|
|
276
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
277
|
+
function fulfill(value) { resume("next", value); }
|
|
278
|
+
function reject(value) { resume("throw", value); }
|
|
279
|
+
function settle(f, v) { if (f(v), q.shift(), q.length)
|
|
280
|
+
resume(q[0][0], q[0][1]); }
|
|
281
|
+
}
|
|
282
|
+
function __asyncDelegator(o) {
|
|
283
|
+
var i, p;
|
|
284
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
285
|
+
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
286
|
+
}
|
|
287
|
+
function __asyncValues(o) {
|
|
288
|
+
if (!Symbol.asyncIterator)
|
|
289
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
290
|
+
var m = o[Symbol.asyncIterator], i;
|
|
291
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
292
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
293
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
294
|
+
}
|
|
295
|
+
function __makeTemplateObject(cooked, raw) {
|
|
296
|
+
if (Object.defineProperty) {
|
|
297
|
+
Object.defineProperty(cooked, "raw", { value: raw });
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
cooked.raw = raw;
|
|
301
|
+
}
|
|
302
|
+
return cooked;
|
|
303
|
+
}
|
|
304
|
+
;
|
|
305
|
+
var __setModuleDefault = Object.create ? (function (o, v) {
|
|
306
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
307
|
+
}) : function (o, v) {
|
|
308
|
+
o["default"] = v;
|
|
309
|
+
};
|
|
310
|
+
function __importStar(mod) {
|
|
311
|
+
if (mod && mod.__esModule)
|
|
312
|
+
return mod;
|
|
313
|
+
var result = {};
|
|
314
|
+
if (mod != null)
|
|
315
|
+
for (var k in mod)
|
|
316
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
317
|
+
__createBinding(result, mod, k);
|
|
318
|
+
__setModuleDefault(result, mod);
|
|
319
|
+
return result;
|
|
320
|
+
}
|
|
321
|
+
function __importDefault(mod) {
|
|
322
|
+
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
323
|
+
}
|
|
324
|
+
function __classPrivateFieldGet(receiver, privateMap) {
|
|
325
|
+
if (!privateMap.has(receiver)) {
|
|
326
|
+
throw new TypeError("attempted to get private field on non-instance");
|
|
327
|
+
}
|
|
328
|
+
return privateMap.get(receiver);
|
|
329
|
+
}
|
|
330
|
+
function __classPrivateFieldSet(receiver, privateMap, value) {
|
|
331
|
+
if (!privateMap.has(receiver)) {
|
|
332
|
+
throw new TypeError("attempted to set private field on non-instance");
|
|
333
|
+
}
|
|
334
|
+
privateMap.set(receiver, value);
|
|
335
|
+
return value;
|
|
336
|
+
}
|
|
11
337
|
|
|
12
338
|
/**
|
|
13
339
|
* Contenitore delle localizzazioni collegate ad un testo "base", una per ogni linguaggio supportato
|
|
@@ -80,15 +406,6 @@
|
|
|
80
406
|
new LocaleObject('en-US', 'English', ['en', 'en-US'])
|
|
81
407
|
];
|
|
82
408
|
|
|
83
|
-
/**
|
|
84
|
-
* Classe di configurazione per il modulo di localizzazione
|
|
85
|
-
*/
|
|
86
|
-
var LocalizationModuleConfig = /** @class */ (function () {
|
|
87
|
-
function LocalizationModuleConfig() {
|
|
88
|
-
}
|
|
89
|
-
return LocalizationModuleConfig;
|
|
90
|
-
}());
|
|
91
|
-
|
|
92
409
|
/**
|
|
93
410
|
* Classe che rappresenta la localizzazione di un test base per una certa lingua
|
|
94
411
|
*/
|
|
@@ -106,77 +423,14 @@
|
|
|
106
423
|
return SpecializedLocalization;
|
|
107
424
|
}());
|
|
108
425
|
|
|
109
|
-
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var BaseLocalization = /** @class */ (function () {
|
|
114
|
-
/**
|
|
115
|
-
* Costruttore. Da qui utilizzando il metodo statico **BaseLocalization.set** si va a popolare la cache delle traduzioni **BaseTranslations**
|
|
116
|
-
*/
|
|
117
|
-
function BaseLocalization() {
|
|
118
|
-
/**
|
|
119
|
-
* Cache di tutte le localizzazioni di base
|
|
120
|
-
*/
|
|
121
|
-
this.BaseTranslations = {};
|
|
122
|
-
// Odio sprecare caratteri... soprattutto quando rischio che non vengano minificati
|
|
123
|
-
var bt = this.BaseTranslations;
|
|
124
|
-
var bl = BaseLocalization;
|
|
125
|
-
bl.set(bt, "en->it", "Remove", ["Elimina"]);
|
|
126
|
-
bl.set(bt, "en->it", "Paging", ["Paginazione"]);
|
|
127
|
-
bl.set(bt, "en->it", "Yes", ["Si"]);
|
|
128
|
-
bl.set(bt, "en->it", "No", ["No"]);
|
|
129
|
-
bl.set(bt, "en->it", "YES", ["SI'"]);
|
|
130
|
-
bl.set(bt, "en->it", "NO", ["NO"]);
|
|
131
|
-
bl.set(bt, "en->it", "Found objects", ["Risultati trovati"]);
|
|
132
|
-
bl.set(bt, "en->it", "Loading data...", ["Carico i dati..."]);
|
|
133
|
-
bl.set(bt, "en->it", "Error during save operations", ["Errori durante il salvataggio"]);
|
|
134
|
-
bl.set(bt, "en->it", "Error", ["Errore"]);
|
|
135
|
-
bl.set(bt, "en->it", "Warning", ["Avviso"]);
|
|
136
|
-
bl.set(bt, "en->it", "Information", ["Informazione"]);
|
|
137
|
-
bl.set(bt, "en->it", "Save", ["Salva"]);
|
|
138
|
-
bl.set(bt, "en->it", "Back", ["Indietro"]);
|
|
139
|
-
bl.set(bt, "en->it", "From", ["Da"]);
|
|
140
|
-
bl.set(bt, "en->it", "To", ["A"]);
|
|
141
|
-
bl.set(bt, "en->it", "View Chart", ["Vedi Grafico"]);
|
|
142
|
-
bl.set(bt, "en->it", "View Table", ["Vedi Tabella"]);
|
|
143
|
-
bl.set(bt, "en->it", "Notes", ["Note"]);
|
|
144
|
-
bl.set(bt, "en->it", "Edit Notes", ["Modifica Note"]);
|
|
145
|
-
bl.set(bt, "en->it", "Cancel", ["Annulla"]);
|
|
146
|
-
bl.set(bt, "en->it", "Confirm", ["Conferma"]);
|
|
147
|
-
bl.set(bt, "en->it", "View", ["Visualizza"]);
|
|
148
|
-
bl.set(bt, "en->it", "Close", ["Chiudi"]);
|
|
149
|
-
bl.set(bt, "en->it", "Select", ["Seleziona"]);
|
|
150
|
-
bl.set(bt, "en->it", "Meter Reading registered successfully", ["Lettura registrata correttamente"]);
|
|
151
|
-
bl.set(bt, "en->it", "Validation errors during save operations", ["Errori di validazione durante il salvataggio"]);
|
|
152
|
-
bl.set(bt, "en->it", "Can't register reading", ["Impossibile registrare la lettura"]);
|
|
153
|
-
bl.set(bt, "en->it", "Electricity", ["Elettricita"]);
|
|
154
|
-
bl.set(bt, "en->it", "Gas", ["Gas"]);
|
|
155
|
-
bl.set(bt, "en->it", "Water", ["Acqua"]);
|
|
156
|
-
bl.set(bt, "en->it", "Delete", ["Elimina"]);
|
|
157
|
-
bl.set(bt, "en->it", "This operation cannot be reverted", ["Questa operazione non puo' essere annullata"]);
|
|
158
|
-
bl.set(bt, "en->it", "Hide", ["Nascondi"]);
|
|
159
|
-
// Helper validazione
|
|
160
|
-
bl.set(bt, "en->it", "Required field", ["Campo richiesto"]);
|
|
161
|
-
bl.set(bt, "en->it", "Wrong field format", ["Formato campo errato"]);
|
|
162
|
-
bl.set(bt, "en->it", "Wrong field format or field missing", ["Formato campo errato o campo mancante"]);
|
|
163
|
-
bl.set(bt, "en->it", "You don't have the required permissions to view this page. The navigation has been blocked", ["Non si hanno privilegi a sufficienza per accedere a questa pagina. La navigazione e' stata bloccata"]);
|
|
164
|
-
// Informazioni sulle date
|
|
165
|
-
bl.setToken(bt, "en->it", "getDateMonthPosition", "0", ["1"]);
|
|
166
|
-
bl.setToken(bt, "en->it", "getDisplayDateMonthPosition", "1", ["1"]);
|
|
167
|
-
bl.setToken(bt, "en->it", "getLocale", "en-US", ["it-IT"]);
|
|
168
|
-
bl.setToken(bt, "en->it", "getSmallDateFormat", "MM/DD/YYYY", ["DD/MM/YYYY"]);
|
|
169
|
-
bl.setToken(bt, "en->it", "getDefaultDateFormat", "MM/DD/YYYY", ["MM/DD/YYYY"]);
|
|
170
|
-
bl.setToken(bt, "en->it", "getSmallDateDisplayFormat", "DD/MM/YYYY", ["DD/MM/YYYY"]);
|
|
171
|
-
bl.setToken(bt, "en->it", "getFullDateFormat", "MM/DD/YYYY HH:mm:ss", ["DD/MM/YYYY HH:mm:ss"]);
|
|
172
|
-
bl.setToken(bt, "en->it", "getFullDateDisplayFormat", "DD/MM/YYYY HH:mm:ss", ["DD/MM/YYYY HH:mm:ss"]);
|
|
173
|
-
bl.setToken(bt, "en->it", "getFullDateFormatNoSeconds", "MM/DD/YYYY HH:mm", ["DD/MM/YYYY HH:mm"]);
|
|
174
|
-
bl.setToken(bt, "en->it", "getFullDateDisplayFormatNoSeconds", "DD/MM/YYYY HH:mm", ["DD/MM/YYYY HH:mm"]);
|
|
426
|
+
var LocalizationPersistor = /** @class */ (function () {
|
|
427
|
+
function LocalizationPersistor(LocCache) {
|
|
428
|
+
if (LocCache === void 0) { LocCache = null; }
|
|
429
|
+
this.LocCache = LocCache;
|
|
175
430
|
}
|
|
176
431
|
/**
|
|
177
432
|
* Imposta la localizzazione di un token all'interno della cache scelta
|
|
178
433
|
*
|
|
179
|
-
* @param {{ [id: string]: ItemLocalization }} locCache Cache all'interno della quale inserire l'informazione del token con le localizzazioni
|
|
180
434
|
* @param {string} direction Direzione della traduzione, rappresenta la lingua base in cui aspettarsi il testo e le varie lingue in cui viene tradotta.
|
|
181
435
|
* Ad esempio, "en->it" indica che il parametro **left** è valido per le localizzazioni in inglese, mentre nell'elemento 0 del parametro **right**
|
|
182
436
|
* è presente l'unica traduzione in italiano, per definire più traduzioni sul lato destro della freccia bisogna concatenarle con la virgola, ad esempio "en->it,jp,ecc"
|
|
@@ -184,56 +438,56 @@
|
|
|
184
438
|
* @param {string} left Valore del token per la lingua specificata nel lato immediatamente sinistro alla freccia del parametro **direction**
|
|
185
439
|
* @param {string} right Array con i valori facenti riferimento all'N-esima lingua del lato destro del parametro **direction**
|
|
186
440
|
*/
|
|
187
|
-
|
|
441
|
+
LocalizationPersistor.prototype.setToken = function (direction, token, left, right) {
|
|
442
|
+
var _this = this;
|
|
188
443
|
var parsingRegex = /([a-zA-Z]+)[\s]*->[\s]*([a-zA-Z,\s]+)+/g;
|
|
189
444
|
var parsingRes = parsingRegex.exec(direction);
|
|
190
445
|
var from = parsingRes[1];
|
|
191
446
|
var to = parsingRes[2].replace(/\s/g, '').split(',');
|
|
192
447
|
var localeFrom = LocaleDefinitions.getByAlias(from);
|
|
193
|
-
|
|
448
|
+
this._set(token, localeFrom.id, left, true);
|
|
194
449
|
to.forEach(function (t, index) {
|
|
195
450
|
var localeTo = LocaleDefinitions.getByAlias(t);
|
|
196
|
-
|
|
451
|
+
_this._set(token, localeTo.id, right[index], true);
|
|
197
452
|
});
|
|
198
453
|
};
|
|
199
454
|
/**
|
|
200
455
|
* Imposta la localizzazione di una frase all'interno della cache scelta
|
|
201
456
|
*
|
|
202
|
-
* @param {{ [id: string]: ItemLocalization }} locCache Cache all'interno della quale inserire l'informazione della frase con le localizzazioni
|
|
203
457
|
* @param {string} direction Direzione della traduzione, rappresenta la lingua base in cui aspettarsi il testo e le varie lingue in cui viene tradotta.
|
|
204
458
|
* Ad esempio, "en->it" indica che il parametro **left** è valido per le localizzazioni in inglese, mentre nell'elemento 0 del parametro **right**
|
|
205
459
|
* è presente l'unica traduzione in italiano, per definire più traduzioni sul lato destro della freccia bisogna concatenarle con la virgola, ad esempio "en->it,jp,ecc"
|
|
206
460
|
* @param {string} left Valore della frase per la lingua specificata nel lato immediatamente sinistro alla freccia del parametro **direction**
|
|
207
461
|
* @param {string} right Array con i valori facenti riferimento all'N-esima lingua del lato destro del parametro **direction**
|
|
208
462
|
*/
|
|
209
|
-
|
|
463
|
+
LocalizationPersistor.prototype.set = function (direction, left, right) {
|
|
464
|
+
var _this = this;
|
|
210
465
|
var parsingRegex = /([a-zA-Z]+)[\s]*->[\s]*([a-zA-Z,\s]+)+/g;
|
|
211
466
|
var parsingRes = parsingRegex.exec(direction);
|
|
212
467
|
var from = parsingRes[1];
|
|
213
468
|
var to = parsingRes[2].replace(/\s/g, '').split(',');
|
|
214
469
|
var localeFrom = LocaleDefinitions.getByAlias(from);
|
|
215
|
-
|
|
470
|
+
this._set(left, localeFrom.id, left);
|
|
216
471
|
to.forEach(function (t, index) {
|
|
217
472
|
var localeTo = LocaleDefinitions.getByAlias(t);
|
|
218
|
-
|
|
473
|
+
_this._set(left, localeTo.id, right[index]);
|
|
219
474
|
});
|
|
220
475
|
};
|
|
221
476
|
/**
|
|
222
477
|
* Imposta all'interno della cache specificata un'unica traduzione partendo da un testo di base
|
|
223
478
|
*
|
|
224
|
-
* @param {{ [id: string]: ItemLocalization }} locCache Cache all'interno della quale inserire l'informazione del testo con le localizzazioni
|
|
225
479
|
* @param {string} text Testo da tradurre
|
|
226
480
|
* @param {string} culture Lingua per cui inserire la traduzione
|
|
227
481
|
* @param {string} translation Traduzione del **text** nella lingua specificata da **culture**
|
|
228
482
|
* @param {boolean} token Indica se il **text** è un token o è una frase normale
|
|
229
483
|
*/
|
|
230
|
-
|
|
231
|
-
var item =
|
|
484
|
+
LocalizationPersistor.prototype._set = function (text, culture, translation, token) {
|
|
485
|
+
var item = this.get(text, token);
|
|
232
486
|
if (!item) {
|
|
233
|
-
|
|
487
|
+
this.LocCache[text] = new ItemLocalization(token, text, [new SpecializedLocalization(culture, translation)]);
|
|
234
488
|
return;
|
|
235
489
|
}
|
|
236
|
-
var trs =
|
|
490
|
+
var trs = this.translationByCulture(item, culture);
|
|
237
491
|
if (trs) {
|
|
238
492
|
console.warn("Localization already loaded for sentence '" + text + "' and culture " + culture);
|
|
239
493
|
return;
|
|
@@ -243,18 +497,15 @@
|
|
|
243
497
|
/**
|
|
244
498
|
* Partendo da una cache di localizzazione, dato un testo che può essere o meno un token, cerca quell'elemento all'interno della cache
|
|
245
499
|
*
|
|
246
|
-
* @param {
|
|
247
|
-
* @param {string} text Testo da cercare nella **locCache**
|
|
500
|
+
* @param {string} text Testo da cercare nella **LocCache**
|
|
248
501
|
* @param {boolean} allowtokens Indica se l'elemento cercato può essere un token o se dev'essere per forza una frase (per evitare rari
|
|
249
502
|
* casi di collisione in cui magari un token è uguale a una frase tradotta)
|
|
250
503
|
*
|
|
251
504
|
* @returns {ItemLocalization} Informazioni di localizzazione per il **text** cercato
|
|
252
505
|
*/
|
|
253
|
-
|
|
254
|
-
var possibleItem =
|
|
255
|
-
|
|
256
|
-
return null;
|
|
257
|
-
var item = allowtokens || !possibleItem.token ? possibleItem : null;
|
|
506
|
+
LocalizationPersistor.prototype.get = function (text, allowtokens) {
|
|
507
|
+
var possibleItem = this.LocCache[text];
|
|
508
|
+
var item = possibleItem && (allowtokens || !possibleItem.token) ? possibleItem : null;
|
|
258
509
|
return item;
|
|
259
510
|
};
|
|
260
511
|
/**
|
|
@@ -265,7 +516,7 @@
|
|
|
265
516
|
*
|
|
266
517
|
* @returns {SpecializedLocalization} Informazioni di localizzazione specifiche della lingua richiesta
|
|
267
518
|
*/
|
|
268
|
-
|
|
519
|
+
LocalizationPersistor.prototype.translationByCulture = function (item, culture) {
|
|
269
520
|
for (var i = 0; i < item.translations.length; i++) {
|
|
270
521
|
var trl = item.translations[i];
|
|
271
522
|
if (trl.culture == culture)
|
|
@@ -273,12 +524,180 @@
|
|
|
273
524
|
}
|
|
274
525
|
return null;
|
|
275
526
|
};
|
|
527
|
+
return LocalizationPersistor;
|
|
528
|
+
}());
|
|
529
|
+
|
|
530
|
+
exports.BaseLocalizationTokens = void 0;
|
|
531
|
+
(function (BaseLocalizationTokens) {
|
|
532
|
+
BaseLocalizationTokens["getDateMonthPosition"] = "getDateMonthPosition";
|
|
533
|
+
BaseLocalizationTokens["getDisplayDateMonthPosition"] = "getDisplayDateMonthPosition";
|
|
534
|
+
BaseLocalizationTokens["getLocale"] = "getLocale";
|
|
535
|
+
BaseLocalizationTokens["getSmallDateFormat"] = "getSmallDateFormat";
|
|
536
|
+
BaseLocalizationTokens["getDefaultDateFormat"] = "getDefaultDateFormat";
|
|
537
|
+
BaseLocalizationTokens["getSmallDateDisplayFormat"] = "getSmallDateDisplayFormat";
|
|
538
|
+
BaseLocalizationTokens["getFullDateFormat"] = "getFullDateFormat";
|
|
539
|
+
BaseLocalizationTokens["getFullDateDisplayFormat"] = "getFullDateDisplayFormat";
|
|
540
|
+
BaseLocalizationTokens["getFullDateFormatNoSeconds"] = "getFullDateFormatNoSeconds";
|
|
541
|
+
BaseLocalizationTokens["getFullDateDisplayFormatNoSeconds"] = "getFullDateDisplayFormatNoSeconds";
|
|
542
|
+
})(exports.BaseLocalizationTokens || (exports.BaseLocalizationTokens = {}));
|
|
543
|
+
|
|
544
|
+
/** Classe astratta che rappresenta lo stato di persistenza fra la libreria e uno storage */
|
|
545
|
+
var LocalePersistor = /** @class */ (function () {
|
|
546
|
+
function LocalePersistor() {
|
|
547
|
+
/** Chiave su cui salvare il locale */
|
|
548
|
+
this.LOCALE = "LOCALE";
|
|
549
|
+
}
|
|
550
|
+
return LocalePersistor;
|
|
551
|
+
}());
|
|
552
|
+
|
|
553
|
+
/** Locale da utilizzare per le traduzioni */
|
|
554
|
+
var LOC_LOCALE = new i0.InjectionToken('LOC_LOCALE');
|
|
555
|
+
/** Policy da utilizzare per traduzioni mancanti */
|
|
556
|
+
var LOC_MISSING_POLICY = new i0.InjectionToken('LOC_MISSING_POLICY');
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Classe singleton che contiene le traduzioni di base (per evitare di ripeterle in oggi classe di traduzione) e le funzioni base per
|
|
560
|
+
* inserire e leggere traduzioni in/da una cache
|
|
561
|
+
*/
|
|
562
|
+
var BaseLocalization = /** @class */ (function () {
|
|
563
|
+
/**
|
|
564
|
+
* Costruttore. Da qui utilizzando il metodo statico **BaseLocalization.set** si va a popolare la cache delle traduzioni **BaseTranslations**
|
|
565
|
+
*/
|
|
566
|
+
function BaseLocalization(LocalePersistor, defaultLocale) {
|
|
567
|
+
var _this = this;
|
|
568
|
+
this.LocalePersistor = LocalePersistor;
|
|
569
|
+
/**
|
|
570
|
+
* Cache di tutte le localizzazioni di base
|
|
571
|
+
*/
|
|
572
|
+
this.LocCache = {};
|
|
573
|
+
/**
|
|
574
|
+
* Locale di riferimento per tutte le traduzioni
|
|
575
|
+
*/
|
|
576
|
+
this.Locale = new rxjs.ReplaySubject(1);
|
|
577
|
+
// Recupero il locale alla partenza del BaseLocalization in modo, spero di dare tempo all'applicazione di tirarlo su
|
|
578
|
+
this.LocalePersistor.recover().pipe(operators.take(1)).subscribe(function (l) { return __awaiter(_this, void 0, void 0, function () {
|
|
579
|
+
return __generator(this, function (_a) {
|
|
580
|
+
if (!l) {
|
|
581
|
+
l = defaultLocale;
|
|
582
|
+
this.LocalePersistor.persist(defaultLocale);
|
|
583
|
+
}
|
|
584
|
+
this.Locale.next(l);
|
|
585
|
+
return [2 /*return*/];
|
|
586
|
+
});
|
|
587
|
+
}); });
|
|
588
|
+
this.Persistor = new LocalizationPersistor(this.LocCache);
|
|
589
|
+
this.Persistor.set("en->it", "Remove", ["Elimina"]);
|
|
590
|
+
this.Persistor.set("en->it", "Paging", ["Paginazione"]);
|
|
591
|
+
this.Persistor.set("en->it", "Yes", ["Si"]);
|
|
592
|
+
this.Persistor.set("en->it", "No", ["No"]);
|
|
593
|
+
this.Persistor.set("en->it", "YES", ["SI'"]);
|
|
594
|
+
this.Persistor.set("en->it", "NO", ["NO"]);
|
|
595
|
+
this.Persistor.set("en->it", "Found objects", ["Risultati trovati"]);
|
|
596
|
+
this.Persistor.set("en->it", "Loading data...", ["Carico i dati..."]);
|
|
597
|
+
this.Persistor.set("en->it", "Error during save operations", ["Errori durante il salvataggio"]);
|
|
598
|
+
this.Persistor.set("en->it", "Error", ["Errore"]);
|
|
599
|
+
this.Persistor.set("en->it", "Warning", ["Avviso"]);
|
|
600
|
+
this.Persistor.set("en->it", "Information", ["Informazione"]);
|
|
601
|
+
this.Persistor.set("en->it", "Save", ["Salva"]);
|
|
602
|
+
this.Persistor.set("en->it", "Back", ["Indietro"]);
|
|
603
|
+
this.Persistor.set("en->it", "From", ["Da"]);
|
|
604
|
+
this.Persistor.set("en->it", "To", ["A"]);
|
|
605
|
+
this.Persistor.set("en->it", "View Chart", ["Vedi Grafico"]);
|
|
606
|
+
this.Persistor.set("en->it", "View Table", ["Vedi Tabella"]);
|
|
607
|
+
this.Persistor.set("en->it", "Notes", ["Note"]);
|
|
608
|
+
this.Persistor.set("en->it", "Edit Notes", ["Modifica Note"]);
|
|
609
|
+
this.Persistor.set("en->it", "Cancel", ["Annulla"]);
|
|
610
|
+
this.Persistor.set("en->it", "Confirm", ["Conferma"]);
|
|
611
|
+
this.Persistor.set("en->it", "View", ["Visualizza"]);
|
|
612
|
+
this.Persistor.set("en->it", "Close", ["Chiudi"]);
|
|
613
|
+
this.Persistor.set("en->it", "Select", ["Seleziona"]);
|
|
614
|
+
this.Persistor.set("en->it", "Meter Reading registered successfully", ["Lettura registrata correttamente"]);
|
|
615
|
+
this.Persistor.set("en->it", "Validation errors during save operations", ["Errori di validazione durante il salvataggio"]);
|
|
616
|
+
this.Persistor.set("en->it", "Can't register reading", ["Impossibile registrare la lettura"]);
|
|
617
|
+
this.Persistor.set("en->it", "Electricity", ["Elettricita"]);
|
|
618
|
+
this.Persistor.set("en->it", "Gas", ["Gas"]);
|
|
619
|
+
this.Persistor.set("en->it", "Water", ["Acqua"]);
|
|
620
|
+
this.Persistor.set("en->it", "Delete", ["Elimina"]);
|
|
621
|
+
this.Persistor.set("en->it", "This operation cannot be reverted", ["Questa operazione non puo' essere annullata"]);
|
|
622
|
+
this.Persistor.set("en->it", "Hide", ["Nascondi"]);
|
|
623
|
+
// Helper validazione
|
|
624
|
+
this.Persistor.set("en->it", "Required field", ["Campo richiesto"]);
|
|
625
|
+
this.Persistor.set("en->it", "Wrong field format", ["Formato campo errato"]);
|
|
626
|
+
this.Persistor.set("en->it", "Wrong field format or field missing", ["Formato campo errato o campo mancante"]);
|
|
627
|
+
this.Persistor.set("en->it", "You don't have the required permissions to view this page. The navigation has been blocked", ["Non si hanno privilegi a sufficienza per accedere a questa pagina. La navigazione e' stata bloccata"]);
|
|
628
|
+
// Informazioni sulle date
|
|
629
|
+
this.Persistor.setToken("en->it", exports.BaseLocalizationTokens.getDateMonthPosition, "0", ["1"]);
|
|
630
|
+
this.Persistor.setToken("en->it", exports.BaseLocalizationTokens.getDisplayDateMonthPosition, "1", ["1"]);
|
|
631
|
+
this.Persistor.setToken("en->it", exports.BaseLocalizationTokens.getLocale, "en-US", ["it-IT"]);
|
|
632
|
+
this.Persistor.setToken("en->it", exports.BaseLocalizationTokens.getSmallDateFormat, "MM/DD/YYYY", ["DD/MM/YYYY"]);
|
|
633
|
+
this.Persistor.setToken("en->it", exports.BaseLocalizationTokens.getDefaultDateFormat, "MM/DD/YYYY", ["MM/DD/YYYY"]);
|
|
634
|
+
this.Persistor.setToken("en->it", exports.BaseLocalizationTokens.getSmallDateDisplayFormat, "DD/MM/YYYY", ["DD/MM/YYYY"]);
|
|
635
|
+
this.Persistor.setToken("en->it", exports.BaseLocalizationTokens.getFullDateFormat, "MM/DD/YYYY HH:mm:ss", ["DD/MM/YYYY HH:mm:ss"]);
|
|
636
|
+
this.Persistor.setToken("en->it", exports.BaseLocalizationTokens.getFullDateDisplayFormat, "DD/MM/YYYY HH:mm:ss", ["DD/MM/YYYY HH:mm:ss"]);
|
|
637
|
+
this.Persistor.setToken("en->it", exports.BaseLocalizationTokens.getFullDateFormatNoSeconds, "MM/DD/YYYY HH:mm", ["DD/MM/YYYY HH:mm"]);
|
|
638
|
+
this.Persistor.setToken("en->it", exports.BaseLocalizationTokens.getFullDateDisplayFormatNoSeconds, "DD/MM/YYYY HH:mm", ["DD/MM/YYYY HH:mm"]);
|
|
639
|
+
}
|
|
276
640
|
return BaseLocalization;
|
|
277
641
|
}());
|
|
642
|
+
BaseLocalization.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function BaseLocalization_Factory() { return new BaseLocalization(i0__namespace.ɵɵinject(LocalePersistor), i0__namespace.ɵɵinject(LOC_LOCALE)); }, token: BaseLocalization, providedIn: "root" });
|
|
278
643
|
BaseLocalization.decorators = [
|
|
279
|
-
{ type:
|
|
644
|
+
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
645
|
+
];
|
|
646
|
+
BaseLocalization.ctorParameters = function () { return [
|
|
647
|
+
{ type: LocalePersistor },
|
|
648
|
+
{ type: String, decorators: [{ type: i0.Inject, args: [LOC_LOCALE,] }] }
|
|
649
|
+
]; };
|
|
650
|
+
|
|
651
|
+
// Angular
|
|
652
|
+
/**
|
|
653
|
+
* Pipe che permette di formattare una data in base al formato specificato. Utilizza il **DateService** di **@esfaenza/extensions** per ricondurre l'input a una data valida
|
|
654
|
+
*/
|
|
655
|
+
var LocDatePipe = /** @class */ (function () {
|
|
656
|
+
/**
|
|
657
|
+
* @ignore
|
|
658
|
+
*/
|
|
659
|
+
function LocDatePipe(dts) {
|
|
660
|
+
this.dts = dts;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Trasformazione della data in input in base al formato richiesto
|
|
664
|
+
*
|
|
665
|
+
* @param {any} value Valore da ricondurre ad una data e formattare
|
|
666
|
+
* @param {string} format Formato in output della data da visualizzare
|
|
667
|
+
*
|
|
668
|
+
* @returns {string} Data formattata in base al formato
|
|
669
|
+
*/
|
|
670
|
+
LocDatePipe.prototype.transform = function (value, format) {
|
|
671
|
+
if (format === void 0) { format = "DD/MM/YYYY"; }
|
|
672
|
+
if (value == null || value === "")
|
|
673
|
+
return null;
|
|
674
|
+
if (!this.dts) {
|
|
675
|
+
console.error("Tentativo di usare loc_date senza DateService. È possibile importare DateService installando e configurando il pacchetto @esfaenza/extensions");
|
|
676
|
+
return null;
|
|
677
|
+
}
|
|
678
|
+
var detatchedValue = JSON.parse(JSON.stringify(value));
|
|
679
|
+
var dt = this.dts.getDateConvertion(detatchedValue);
|
|
680
|
+
return dt.format(format);
|
|
681
|
+
};
|
|
682
|
+
return LocDatePipe;
|
|
683
|
+
}());
|
|
684
|
+
LocDatePipe.decorators = [
|
|
685
|
+
{ type: i0.Pipe, args: [{ name: "loc_date", pure: true },] }
|
|
280
686
|
];
|
|
281
|
-
|
|
687
|
+
LocDatePipe.ctorParameters = function () { return [
|
|
688
|
+
{ type: extensions.DateService, decorators: [{ type: i0.Optional }] }
|
|
689
|
+
]; };
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Enum che rappresenta le policy di comportamento qualore il sistema di localizzazione non trovi la localizzazione cercata,
|
|
693
|
+
* usare **ThrowException** solo se ci si sente infallibili o si vuole debuggare in maniera approfondita l'applicazione
|
|
694
|
+
*/
|
|
695
|
+
exports.LocalizationMissingPolicy = void 0;
|
|
696
|
+
(function (LocalizationMissingPolicy) {
|
|
697
|
+
LocalizationMissingPolicy[LocalizationMissingPolicy["PrintEmpty"] = 0] = "PrintEmpty";
|
|
698
|
+
LocalizationMissingPolicy[LocalizationMissingPolicy["PrintSource"] = 1] = "PrintSource";
|
|
699
|
+
LocalizationMissingPolicy[LocalizationMissingPolicy["ThrowException"] = 2] = "ThrowException";
|
|
700
|
+
})(exports.LocalizationMissingPolicy || (exports.LocalizationMissingPolicy = {}));
|
|
282
701
|
|
|
283
702
|
/**
|
|
284
703
|
* Classe di localizzazione estendibile che permette di specificare le proprie localizzazioni e comunque rendere disponibili le localizzazioni globali
|
|
@@ -287,17 +706,24 @@
|
|
|
287
706
|
/**
|
|
288
707
|
* Costruttore
|
|
289
708
|
*
|
|
290
|
-
* @param {string}
|
|
709
|
+
* @param {string} Locale Locale da utilizzare nel momento che questo servizio richiede le traduzioni
|
|
291
710
|
* @param {baseLocalization} baseLocalization Classe base di localizzazione già fornita a livello di root dalla libreria stessa.
|
|
292
711
|
* È sufficiente iniettarla nell'eventuale costruttore che estende questa classe e passarla as-is
|
|
293
712
|
*/
|
|
294
|
-
function LocalizationService(
|
|
295
|
-
|
|
296
|
-
this.
|
|
713
|
+
function LocalizationService(injector) {
|
|
714
|
+
var _this = this;
|
|
715
|
+
this.injector = injector;
|
|
297
716
|
/**
|
|
298
717
|
* Cache di tutte le localizzazioni disonibili all'interno di questa classe
|
|
299
718
|
*/
|
|
300
719
|
this.TranslationCache = {};
|
|
720
|
+
this.LocalePersistor = this.injector.get(LocalePersistor);
|
|
721
|
+
this.baseLocalization = this.injector.get(BaseLocalization);
|
|
722
|
+
this.onMissing = this.injector.get(LOC_MISSING_POLICY);
|
|
723
|
+
this.Persistor = new LocalizationPersistor(this.TranslationCache);
|
|
724
|
+
this.baseLocalization.Locale.subscribe(function (lr) {
|
|
725
|
+
_this.Locale = lr;
|
|
726
|
+
});
|
|
301
727
|
}
|
|
302
728
|
/**
|
|
303
729
|
* Imposta la localizzazione di un token all'interno della **TranslationCache**
|
|
@@ -310,7 +736,7 @@
|
|
|
310
736
|
* @param {string} right Array con i valori facenti riferimento all'N-esima lingua del lato destro del parametro **direction**
|
|
311
737
|
*/
|
|
312
738
|
LocalizationService.prototype.setToken = function (direction, token, left, right) {
|
|
313
|
-
|
|
739
|
+
this.Persistor.setToken(direction, token, left, right);
|
|
314
740
|
};
|
|
315
741
|
/**
|
|
316
742
|
* Imposta la localizzazione di una frase all'interno della **TranslationCache**
|
|
@@ -322,7 +748,13 @@
|
|
|
322
748
|
* @param {string} right Array con i valori facenti riferimento all'N-esima lingua del lato destro del parametro **direction**
|
|
323
749
|
*/
|
|
324
750
|
LocalizationService.prototype.set = function (direction, left, right) {
|
|
325
|
-
|
|
751
|
+
// Controlla di non reinserire la stessa localizzazione presente nel BaseLocalization
|
|
752
|
+
// i controlli per il non reinserimento della stessa localizzazione all'interno della stessa istanza è fatto lato Persistor
|
|
753
|
+
if (this.baseLocalization.Persistor.get(left, false)) {
|
|
754
|
+
console.warn("La localizzazione per " + left + " \u00E8 gi\u00E0 presente fra le localizzazioni base, ignoro l'operazione");
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
this.Persistor.set(direction, left, right);
|
|
326
758
|
};
|
|
327
759
|
/**
|
|
328
760
|
* Localizza un token
|
|
@@ -343,88 +775,60 @@
|
|
|
343
775
|
* @returns {string} Frase localizzata
|
|
344
776
|
*/
|
|
345
777
|
LocalizationService.prototype.loc = function (text, allowtokens) {
|
|
778
|
+
if (!this.Locale)
|
|
779
|
+
throw "Il sistema di localizzazione non ha ancora caricato il Locale, assicurarsi di caricare l'APP solo al retrieve del locale'";
|
|
346
780
|
if (!text || text == "undefined")
|
|
347
781
|
return "";
|
|
348
|
-
// Questo può succedere solo se qualcuno crea questa service a manazza. In quel caso prendo la classe di default e basta
|
|
349
|
-
if (this.baseLocalization == null)
|
|
350
|
-
this.baseLocalization = new BaseLocalization();
|
|
351
782
|
// Prendo la localizzazione o dalla cache attuale o dalla cache del servizio base
|
|
352
|
-
var item =
|
|
783
|
+
var item = this.Persistor.get(text, allowtokens) || this.baseLocalization.Persistor.get(text, allowtokens);
|
|
353
784
|
if (!item) {
|
|
354
|
-
|
|
355
|
-
|
|
785
|
+
var message = "Impossibile trovare la localizzazione per '" + text + "'";
|
|
786
|
+
switch (this.onMissing) {
|
|
787
|
+
case exports.LocalizationMissingPolicy.PrintEmpty:
|
|
788
|
+
console.error(message);
|
|
789
|
+
return "";
|
|
790
|
+
case exports.LocalizationMissingPolicy.PrintSource:
|
|
791
|
+
console.warn(message);
|
|
792
|
+
return text;
|
|
793
|
+
case exports.LocalizationMissingPolicy.ThrowException:
|
|
794
|
+
throw message;
|
|
795
|
+
}
|
|
356
796
|
}
|
|
357
|
-
var loc =
|
|
797
|
+
var loc = this.Persistor.translationByCulture(item, this.Locale);
|
|
358
798
|
if (!loc) {
|
|
359
|
-
console.error("
|
|
799
|
+
console.error("Impossibile trovare la localizzazione per '" + text + "', culture " + this.Locale);
|
|
360
800
|
return "";
|
|
361
801
|
}
|
|
362
802
|
return loc.translation;
|
|
363
803
|
};
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
804
|
+
LocalizationService.prototype.changeLocale = function (newLocale) {
|
|
805
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
806
|
+
var locale;
|
|
807
|
+
return __generator(this, function (_a) {
|
|
808
|
+
switch (_a.label) {
|
|
809
|
+
case 0: return [4 /*yield*/, this.LocalePersistor.recover().toPromise()];
|
|
810
|
+
case 1:
|
|
811
|
+
locale = _a.sent();
|
|
812
|
+
if (!(newLocale == locale)) return [3 /*break*/, 2];
|
|
813
|
+
console.info("Il locale richiesto è lo stesso del locale attuale. Ignoro l'operazione");
|
|
814
|
+
return [2 /*return*/];
|
|
815
|
+
case 2: return [4 /*yield*/, this.LocalePersistor.persist(newLocale).toPromise()];
|
|
816
|
+
case 3:
|
|
817
|
+
_a.sent();
|
|
818
|
+
location.reload();
|
|
819
|
+
_a.label = 4;
|
|
820
|
+
case 4: return [2 /*return*/];
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
});
|
|
379
824
|
};
|
|
380
825
|
return LocalizationService;
|
|
381
826
|
}());
|
|
382
827
|
LocalizationService.decorators = [
|
|
383
|
-
{ type:
|
|
828
|
+
{ type: i0.Injectable }
|
|
384
829
|
];
|
|
385
830
|
LocalizationService.ctorParameters = function () { return [
|
|
386
|
-
{ type:
|
|
387
|
-
{ type: BaseLocalization }
|
|
388
|
-
]; };
|
|
389
|
-
|
|
390
|
-
// Angular
|
|
391
|
-
/**
|
|
392
|
-
* Pipe che permette di formattare una data in base al formato specificato. Utilizza il **DateService** di **@esfaenza/extensions** per ricondurre l'input a una data valida
|
|
393
|
-
*/
|
|
394
|
-
var LocDatePipe = /** @class */ (function () {
|
|
395
|
-
/**
|
|
396
|
-
* @ignore
|
|
397
|
-
*/
|
|
398
|
-
function LocDatePipe(dts) {
|
|
399
|
-
this.dts = dts;
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Trasformazione della data in input in base al formato richiesto
|
|
403
|
-
*
|
|
404
|
-
* @param {any} value Valore da ricondurre ad una data e formattare
|
|
405
|
-
* @param {string} format Formato in output della data da visualizzare
|
|
406
|
-
*
|
|
407
|
-
* @returns {string} Data formattata in base al formato
|
|
408
|
-
*/
|
|
409
|
-
LocDatePipe.prototype.transform = function (value, format) {
|
|
410
|
-
if (format === void 0) { format = "DD/MM/YYYY"; }
|
|
411
|
-
if (value == null || value === "")
|
|
412
|
-
return null;
|
|
413
|
-
if (!this.dts) {
|
|
414
|
-
console.error("Tentativo di usare loc_date senza DateService. È possibile importare DateService installando e configurando il pacchetto @esfaenza/extensions");
|
|
415
|
-
return null;
|
|
416
|
-
}
|
|
417
|
-
var detatchedValue = JSON.parse(JSON.stringify(value));
|
|
418
|
-
var dt = this.dts.getDateConvertion(detatchedValue);
|
|
419
|
-
return dt.format(format);
|
|
420
|
-
};
|
|
421
|
-
return LocDatePipe;
|
|
422
|
-
}());
|
|
423
|
-
LocDatePipe.decorators = [
|
|
424
|
-
{ type: core.Pipe, args: [{ name: "loc_date", pure: true },] }
|
|
425
|
-
];
|
|
426
|
-
LocDatePipe.ctorParameters = function () { return [
|
|
427
|
-
{ type: extensions.DateService, decorators: [{ type: core.Optional }] }
|
|
831
|
+
{ type: i0.Injector }
|
|
428
832
|
]; };
|
|
429
833
|
|
|
430
834
|
// Angular
|
|
@@ -458,12 +862,34 @@
|
|
|
458
862
|
return LocalizePipe;
|
|
459
863
|
}());
|
|
460
864
|
LocalizePipe.decorators = [
|
|
461
|
-
{ type:
|
|
865
|
+
{ type: i0.Pipe, args: [{ name: "localize", pure: true },] }
|
|
462
866
|
];
|
|
463
867
|
LocalizePipe.ctorParameters = function () { return [
|
|
464
868
|
{ type: LocalizationService }
|
|
465
869
|
]; };
|
|
466
870
|
|
|
871
|
+
var LocalStorageLocalePersistor = /** @class */ (function (_super) {
|
|
872
|
+
__extends(LocalStorageLocalePersistor, _super);
|
|
873
|
+
function LocalStorageLocalePersistor() {
|
|
874
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
875
|
+
}
|
|
876
|
+
/** @ignore Vedi classe base */
|
|
877
|
+
LocalStorageLocalePersistor.prototype.persist = function (locale) {
|
|
878
|
+
localStorage.setItem(this.LOCALE, locale);
|
|
879
|
+
return rxjs.of(true).pipe(operators.first());
|
|
880
|
+
};
|
|
881
|
+
/** @ignore Vedi classe base */
|
|
882
|
+
LocalStorageLocalePersistor.prototype.recover = function () {
|
|
883
|
+
var ret = localStorage.getItem(this.LOCALE);
|
|
884
|
+
return rxjs.of(ret).pipe(operators.first());
|
|
885
|
+
};
|
|
886
|
+
return LocalStorageLocalePersistor;
|
|
887
|
+
}(LocalePersistor));
|
|
888
|
+
LocalStorageLocalePersistor.decorators = [
|
|
889
|
+
{ type: i0.Injectable }
|
|
890
|
+
];
|
|
891
|
+
|
|
892
|
+
// Angular
|
|
467
893
|
var LocalizationModule = /** @class */ (function () {
|
|
468
894
|
function LocalizationModule() {
|
|
469
895
|
}
|
|
@@ -473,19 +899,30 @@
|
|
|
473
899
|
providers: [
|
|
474
900
|
LocalizationService,
|
|
475
901
|
BaseLocalization,
|
|
476
|
-
{ provide: LOC_LOCALE, useValue: (config === null || config === void 0 ? void 0 : config.
|
|
902
|
+
{ provide: LOC_LOCALE, useValue: (config === null || config === void 0 ? void 0 : config.defaultLocale) || 'it-IT' },
|
|
903
|
+
{ provide: LOC_MISSING_POLICY, useValue: (config === null || config === void 0 ? void 0 : config.localizationMissingPolicy) || exports.LocalizationMissingPolicy.PrintEmpty },
|
|
904
|
+
{ provide: LocalePersistor, useClass: (config === null || config === void 0 ? void 0 : config.localePersistor) || LocalStorageLocalePersistor },
|
|
477
905
|
]
|
|
478
906
|
};
|
|
479
907
|
};
|
|
480
908
|
return LocalizationModule;
|
|
481
909
|
}());
|
|
482
910
|
LocalizationModule.decorators = [
|
|
483
|
-
{ type:
|
|
911
|
+
{ type: i0.NgModule, args: [{
|
|
484
912
|
declarations: [LocalizePipe, LocDatePipe],
|
|
485
913
|
exports: [LocalizePipe, LocDatePipe]
|
|
486
914
|
},] }
|
|
487
915
|
];
|
|
488
916
|
|
|
917
|
+
/**
|
|
918
|
+
* Classe di configurazione per il modulo di localizzazione
|
|
919
|
+
*/
|
|
920
|
+
var LocalizationModuleConfig = /** @class */ (function () {
|
|
921
|
+
function LocalizationModuleConfig() {
|
|
922
|
+
}
|
|
923
|
+
return LocalizationModuleConfig;
|
|
924
|
+
}());
|
|
925
|
+
|
|
489
926
|
/*
|
|
490
927
|
* Public API Surface of localizations
|
|
491
928
|
*/
|
|
@@ -494,13 +931,16 @@
|
|
|
494
931
|
* Generated bundle index. Do not edit.
|
|
495
932
|
*/
|
|
496
933
|
|
|
934
|
+
exports.BaseLocalization = BaseLocalization;
|
|
497
935
|
exports.LOC_LOCALE = LOC_LOCALE;
|
|
936
|
+
exports.LOC_MISSING_POLICY = LOC_MISSING_POLICY;
|
|
498
937
|
exports.LocDatePipe = LocDatePipe;
|
|
499
938
|
exports.LocalizationModule = LocalizationModule;
|
|
500
939
|
exports.LocalizationModuleConfig = LocalizationModuleConfig;
|
|
501
940
|
exports.LocalizationService = LocalizationService;
|
|
502
941
|
exports.LocalizePipe = LocalizePipe;
|
|
503
|
-
exports.ɵa =
|
|
942
|
+
exports.ɵa = LocalePersistor;
|
|
943
|
+
exports.ɵb = LocalStorageLocalePersistor;
|
|
504
944
|
|
|
505
945
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
506
946
|
|