@zeesoft/i18n-verify 1.0.0 → 2.0.1

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,626 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = () => `
8
+ //Overview
9
+ (() => {
10
+ document.addEventListener("DOMContentLoaded", function () {
11
+ let overviewChart,
12
+ stringChart,
13
+ dateTimeChart,
14
+ numberChart,
15
+ ignoredChart;
16
+
17
+ window.persistOverviewCharts = () => {
18
+ const reset = (chart) => {
19
+ chart.resetSeries(true, true);
20
+ };
21
+
22
+ reset(overviewChart);
23
+ reset(stringChart);
24
+ reset(dateTimeChart);
25
+ reset(numberChart);
26
+ reset(ignoredChart);
27
+ };
28
+
29
+ renderOverallChart();
30
+ renderStringChart();
31
+ renderIgnoredChart();
32
+ renderNumberChart();
33
+ renderDatetimeChart();
34
+
35
+ function renderOverallChart() {
36
+ const reviewed = 2000;
37
+ const locales = 2;
38
+ const type = {
39
+ I18NED: "Internationalized",
40
+ NOT_I18NED: "Not Internationalized",
41
+ SKIPPED: "Skipped",
42
+ },
43
+ valueMap = {
44
+ [type.I18NED]: 1500,
45
+ [type.NOT_I18NED]: 400,
46
+ [type.SKIPPED]: 100,
47
+ },
48
+ percentageCalc = (value) => ((value / reviewed) * 100).toFixed(0);
49
+
50
+ var options = {
51
+ series: [
52
+ {
53
+ name: "",
54
+ data: [
55
+ percentageCalc(valueMap[type.I18NED]),
56
+ percentageCalc(valueMap[type.NOT_I18NED]),
57
+ percentageCalc(valueMap[type.SKIPPED]),
58
+ ],
59
+ },
60
+ ],
61
+ chart: {
62
+ type: "bar",
63
+ height: 200,
64
+ toolbar: {
65
+ show: false,
66
+ },
67
+ animations: {
68
+ enabled: true,
69
+ easing: "easeinout",
70
+ speed: 800,
71
+ animateGradually: {
72
+ enabled: true,
73
+ delay: 150,
74
+ },
75
+ dynamicAnimation: {
76
+ enabled: true,
77
+ speed: 350,
78
+ },
79
+ },
80
+ },
81
+ plotOptions: {
82
+ bar: {
83
+ horizontal: true,
84
+ borderRadius: 3,
85
+ dataLabels: {
86
+ position: "right",
87
+ },
88
+ },
89
+ },
90
+ title: {
91
+ text: \`Total Reviewed strings in \${locales} locales: \${reviewed}\`,
92
+ align: "center",
93
+ floating: true,
94
+ style: {
95
+ fontSize: "14px",
96
+ fontWeight: "bold",
97
+ },
98
+ },
99
+ dataLabels: {
100
+ enabled: true,
101
+ style: {
102
+ colors: ["#080404b0"],
103
+ },
104
+ formatter: (val) => {
105
+ return \`\${val}%\`;
106
+ },
107
+ },
108
+ xaxis: {
109
+ categories: [type.I18NED, type.NOT_I18NED, type.SKIPPED],
110
+ min: 0,
111
+ max: 100,
112
+ labels: {
113
+ formatter: (v) => \`\${v}%\`,
114
+ },
115
+ },
116
+ yaxis: {
117
+ labels: {
118
+ style: {
119
+ fontSize: "13px",
120
+ },
121
+ },
122
+ },
123
+ colors: [
124
+ (v) => {
125
+ switch (v.dataPointIndex) {
126
+ case 0:
127
+ return "#31E994"; //green
128
+ case 1:
129
+ return "#ff8173"; //red
130
+ case 2:
131
+ return "#f5eb5f"; //yellow
132
+ }
133
+ },
134
+ ],
135
+ tooltip: {
136
+ theme: "dark",
137
+ x: {
138
+ formatter: function (v) {
139
+ switch (v) {
140
+ case type.NOT_I18NED:
141
+ return \`Total Number of \${v}, Partially Localized and Encoding issue instances\`;
142
+
143
+ default:
144
+ return \`Total Number of \${v} instances\`;
145
+ }
146
+ },
147
+ },
148
+ y: {
149
+ formatter: function (v) {
150
+ return \`\${v}%\`;
151
+ },
152
+ },
153
+ },
154
+ };
155
+
156
+ (overviewChart = new ApexCharts(
157
+ document.querySelector(".overall-quality .graph"),
158
+ options
159
+ )).render();
160
+ }
161
+
162
+ function renderStringChart() {
163
+ const type = {
164
+ LOCALIZED: "Localized",
165
+ PARTIAL: "Partially Localized",
166
+ NOT_LOCALIZED: "Not Localized",
167
+ UNTRANSLATED: "Untranslated",
168
+ ENCODING: "Encoding Issue",
169
+ IGNORED: "Ignored",
170
+ },
171
+ valueMap = {
172
+ [type.LOCALIZED]: 8000,
173
+ [type.PARTIAL]: 1200,
174
+ [type.NOT_LOCALIZED]: 300,
175
+ [type.UNTRANSLATED]: 500,
176
+ [type.ENCODING]: 250,
177
+ [type.IGNORED]: 250,
178
+ },
179
+ total = Object.values(valueMap).reduce(
180
+ (acc, curr) => acc + curr,
181
+ 0
182
+ ),
183
+ options = {
184
+ series: [
185
+ valueMap[type.LOCALIZED],
186
+ valueMap[type.PARTIAL],
187
+ valueMap[type.NOT_LOCALIZED],
188
+ valueMap[type.IGNORED],
189
+ valueMap[type.ENCODING],
190
+ valueMap[type.UNTRANSLATED],
191
+ ],
192
+ chart: {
193
+ width: 430,
194
+ type: "pie",
195
+ animations: {
196
+ enabled: true,
197
+ easing: "easeinout",
198
+ speed: 800,
199
+ animateGradually: {
200
+ enabled: true,
201
+ delay: 150,
202
+ },
203
+ dynamicAnimation: {
204
+ enabled: true,
205
+ speed: 350,
206
+ },
207
+ },
208
+ },
209
+ labels: [
210
+ type.LOCALIZED,
211
+ type.PARTIAL,
212
+ type.NOT_LOCALIZED,
213
+ type.IGNORED,
214
+ type.ENCODING,
215
+ type.UNTRANSLATED,
216
+ ],
217
+ tooltip: {
218
+ theme: "dark",
219
+ y: {
220
+ formatter: function (v, { config }) {
221
+ return \`\${Number(
222
+ (v /
223
+ config.series.reduce((acc, curr) => acc + curr, 0)) *
224
+ 100
225
+ ).toFixed(0)}%\`;
226
+ },
227
+ title: {
228
+ formatter: function (a) {
229
+ return \`Total Number of \${a} strings including all locales\`;
230
+ },
231
+ },
232
+ },
233
+ },
234
+ colors: [
235
+ ({ seriesIndex, w }) => {
236
+ const currType = w.config.labels[seriesIndex];
237
+
238
+ switch (currType) {
239
+ case type.LOCALIZED:
240
+ return "#31E994";
241
+ case type.NOT_LOCALIZED:
242
+ return "#E44242";
243
+ case type.PARTIAL:
244
+ return "#DADF40";
245
+ case type.UNTRANSLATED:
246
+ return "#4C57EC";
247
+ case type.IGNORED:
248
+ return "#AFA6AB";
249
+ case type.ENCODING:
250
+ return "#F44E9E";
251
+
252
+ default:
253
+ return "";
254
+ }
255
+ },
256
+ ],
257
+ legend: {
258
+ offsetX: -50,
259
+ width: 170,
260
+ formatter: (seriesName, a, b, c) =>
261
+ \`\${seriesName} (\${(
262
+ (valueMap[seriesName] / total) *
263
+ 100
264
+ ).toFixed(0)}%)\`,
265
+ },
266
+ dataLabels: {
267
+ formatter: (v) => \`\${Number(v).toFixed(0)}%\`,
268
+ dropShadow: { enabled: false },
269
+ style: {
270
+ colors: ["#080404b0"],
271
+ },
272
+ },
273
+ };
274
+
275
+ (stringChart = new ApexCharts(
276
+ document.querySelector(".string-quality .graph"),
277
+ options
278
+ )).render();
279
+ }
280
+
281
+ function renderIgnoredChart() {
282
+ const type = {
283
+ DNT: "DNT",
284
+ IGNORED: "Ignored",
285
+ AUTO_IGNORED: "User Inputs",
286
+ },
287
+ valueMap = {
288
+ [type.DNT]: 50,
289
+ [type.IGNORED]: 10,
290
+ [type.AUTO_IGNORED]: 137,
291
+ },
292
+ total = Object.values(valueMap).reduce(
293
+ (acc, curr) => acc + curr,
294
+ 0
295
+ );
296
+ options = {
297
+ series: [
298
+ valueMap[type.DNT],
299
+ valueMap[type.IGNORED],
300
+ valueMap[type.AUTO_IGNORED],
301
+ ],
302
+ chart: {
303
+ width: 385,
304
+ type: "pie",
305
+ animations: {
306
+ enabled: true,
307
+ easing: "easeinout",
308
+ speed: 800,
309
+ animateGradually: {
310
+ enabled: true,
311
+ delay: 150,
312
+ },
313
+ dynamicAnimation: {
314
+ enabled: true,
315
+ speed: 350,
316
+ },
317
+ },
318
+ },
319
+ labels: [type.DNT, type.IGNORED, type.AUTO_IGNORED],
320
+ tooltip: {
321
+ theme: "dark",
322
+ y: {
323
+ formatter: function (v, { config }) {
324
+ return \`\${Number(
325
+ (v / config.series.reduce((acc, curr) => acc + curr, 0)) *
326
+ 100
327
+ ).toFixed(0)}%\`;
328
+ },
329
+ title: {
330
+ formatter: function (a) {
331
+ return \`Total Number of localized \${a} instances including all locales\`;
332
+ },
333
+ },
334
+ },
335
+ },
336
+ colors: [
337
+ ({ seriesIndex, w }) => {
338
+ const currType = w.config.labels[seriesIndex];
339
+
340
+ switch (currType) {
341
+ case type.DNT:
342
+ return "#31E994";
343
+ case type.IGNORED:
344
+ return "#3AD1F3";
345
+ case type.AUTO_IGNORED:
346
+ return "#DADF40";
347
+
348
+ default:
349
+ return "";
350
+ }
351
+ },
352
+ ],
353
+ legend: {
354
+ offsetX: -40,
355
+ formatter: (seriesName) =>
356
+ \`\${seriesName} (\${(
357
+ (valueMap[seriesName] / total) *
358
+ 100
359
+ ).toFixed(0)}%)\`,
360
+ },
361
+ dataLabels: {
362
+ formatter: (v) => \`\${Number(v).toFixed(0)}%\`,
363
+ style: {
364
+ colors: ["#080404b0"],
365
+ },
366
+ dropShadow: { enabled: false },
367
+ },
368
+ };
369
+
370
+ (ignoredChart = new ApexCharts(
371
+ document.querySelector(".skipped-items .graph"),
372
+ options
373
+ )).render();
374
+ }
375
+
376
+ function renderNumberChart() {
377
+ const types = ["Number", "Currency", "Percentage"],
378
+ data = {
379
+ number_i18n: 25,
380
+ currency_i18n: 10,
381
+ percentage_i18n: 4,
382
+ number_not_i18n: 10,
383
+ currency_not_i18n: 3,
384
+ percentage_not_i18n: 7,
385
+ },
386
+ total = Object.values(data).reduce((acc, curr) => acc + curr, 0),
387
+ percentageCalc = (v, t) => ((v / t) * 100).toFixed(0),
388
+ i18nPercentage = percentageCalc(
389
+ data.number_i18n + data.percentage_i18n + data.currency_i18n,
390
+ total
391
+ ),
392
+ nonI18nPercentage = percentageCalc(
393
+ data.number_not_i18n +
394
+ data.percentage_not_i18n +
395
+ data.currency_not_i18n,
396
+ total
397
+ ),
398
+ numberTotal = data.number_i18n + data.number_not_i18n,
399
+ currencyTotal = data.currency_i18n + data.currency_not_i18n,
400
+ percentageTotal = data.percentage_i18n + data.percentage_not_i18n,
401
+ numberI18n = percentageCalc(data.number_i18n, numberTotal),
402
+ currencyI18n = percentageCalc(data.currency_i18n, currencyTotal),
403
+ percentageI18n = percentageCalc(
404
+ data.percentage_i18n,
405
+ currencyTotal
406
+ ),
407
+ numberNotI18n = percentageCalc(data.number_not_i18n, numberTotal),
408
+ currencyNotI18n = percentageCalc(
409
+ data.currency_not_i18n,
410
+ currencyTotal
411
+ ),
412
+ percentageNotI18n = percentageCalc(
413
+ data.percentage_not_i18n,
414
+ currencyTotal
415
+ ),
416
+ options = {
417
+ series: [
418
+ {
419
+ name: "Internationalized",
420
+ data: [numberI18n, currencyI18n, percentageI18n],
421
+ },
422
+ {
423
+ name: "Not Internationalized",
424
+ data: [numberNotI18n, currencyNotI18n, percentageNotI18n],
425
+ },
426
+ ],
427
+ chart: {
428
+ type: "bar",
429
+ height: 220,
430
+ width: 500,
431
+ toolbar: {
432
+ show: false,
433
+ },
434
+ animations: {
435
+ enabled: true,
436
+ easing: "easeinout",
437
+ speed: 800,
438
+ animateGradually: {
439
+ enabled: true,
440
+ delay: 150,
441
+ },
442
+ dynamicAnimation: {
443
+ enabled: true,
444
+ speed: 350,
445
+ },
446
+ },
447
+ },
448
+ dataLabels: {
449
+ enabled: true,
450
+ dropShadow: { enabled: false },
451
+ style: {
452
+ colors: ["#080404b0"],
453
+ },
454
+ formatter: (val) => {
455
+ return \`\${val}%\`;
456
+ },
457
+ },
458
+ stroke: {
459
+ show: true,
460
+ width: 1,
461
+ colors: ["#fff"],
462
+ },
463
+ tooltip: {
464
+ theme: "dark",
465
+ shared: true,
466
+ intersect: false,
467
+ },
468
+ xaxis: {
469
+ categories: types,
470
+ },
471
+ yaxis: {
472
+ min: 0,
473
+ max: 100,
474
+ labels: {
475
+ formatter: (v) => \`\${v}%\`,
476
+ },
477
+ },
478
+ colors: ["#31E994", "#ff8173"],
479
+ legend: {
480
+ offsetX: -13,
481
+ position: "right",
482
+ formatter: (seriesName) => {
483
+ if (seriesName === "Internationalized") {
484
+ return \`\${seriesName} (\${i18nPercentage}%)\`;
485
+ }
486
+ return \`\${seriesName} (\${nonI18nPercentage}%)\`;
487
+ },
488
+ },
489
+ plotOptions: {
490
+ bar: {
491
+ borderRadius: 3,
492
+ columnWidth: "85%",
493
+ },
494
+ },
495
+ };
496
+
497
+ (numberChart = new ApexCharts(
498
+ document.querySelector(".number-quality .graph"),
499
+ options
500
+ )).render();
501
+ }
502
+
503
+ function renderDatetimeChart() {
504
+ const types = ["Date", "Time", "DateTime"],
505
+ data = {
506
+ date_i18n: 10,
507
+ time_i18n: 35,
508
+ date_time_i18n: 17,
509
+ date_not_i18n: 28,
510
+ time_not_i18n: 12,
511
+ date_time_not_i18n: 5,
512
+ },
513
+ total = Object.values(data).reduce((acc, curr) => acc + curr, 0),
514
+ percentageCalc = (v, t) => ((v / t) * 100).toFixed(0),
515
+ i18nPercentage = percentageCalc(
516
+ data.date_i18n + data.time_i18n + data.date_time_i18n,
517
+ total
518
+ ),
519
+ nonI18nPercentage = percentageCalc(
520
+ data.date_not_i18n +
521
+ data.time_not_i18n +
522
+ data.date_time_not_i18n,
523
+ total
524
+ ),
525
+ dateTotal = data.date_i18n + data.date_not_i18n,
526
+ timeTotal = data.time_i18n + data.time_not_i18n,
527
+ dateTimeTotal = data.date_time_i18n + data.date_time_not_i18n,
528
+ dateI18n = percentageCalc(data.date_i18n, dateTotal),
529
+ timeI18n = percentageCalc(data.time_i18n, timeTotal),
530
+ dateTimeI18n = percentageCalc(data.date_time_i18n, dateTimeTotal),
531
+ dateNotI18n = percentageCalc(data.date_not_i18n, dateTotal),
532
+ timeNotI18n = percentageCalc(data.time_not_i18n, timeTotal),
533
+ dateTimeNotI18n = percentageCalc(
534
+ data.date_time_not_i18n,
535
+ dateTimeTotal
536
+ ),
537
+ options = {
538
+ series: [
539
+ {
540
+ name: "Internationalized",
541
+ data: [dateI18n, timeI18n, dateTimeI18n],
542
+ },
543
+ {
544
+ name: "Not Internationalized",
545
+ data: [dateNotI18n, timeNotI18n, dateTimeNotI18n],
546
+ },
547
+ ],
548
+ chart: {
549
+ type: "bar",
550
+ height: 220,
551
+ width: 500,
552
+ toolbar: {
553
+ show: false,
554
+ },
555
+ animations: {
556
+ enabled: true,
557
+ easing: "easeinout",
558
+ speed: 800,
559
+ animateGradually: {
560
+ enabled: true,
561
+ delay: 150,
562
+ },
563
+ dynamicAnimation: {
564
+ enabled: true,
565
+ speed: 350,
566
+ },
567
+ },
568
+ },
569
+ dataLabels: {
570
+ enabled: true,
571
+ dropShadow: { enabled: false },
572
+ style: {
573
+ colors: ["#080404b0"],
574
+ },
575
+ formatter: (val) => {
576
+ return \`\${val}%\`;
577
+ },
578
+ },
579
+ stroke: {
580
+ show: true,
581
+ width: 1,
582
+ colors: ["#fff"],
583
+ },
584
+ tooltip: {
585
+ theme: "dark",
586
+ shared: true,
587
+ intersect: false,
588
+ },
589
+ xaxis: {
590
+ categories: types,
591
+ },
592
+ yaxis: {
593
+ min: 0,
594
+ max: 100,
595
+ labels: {
596
+ formatter: (v) => \`\${v}%\`,
597
+ },
598
+ },
599
+ colors: ["#31E994", "#ff8173"],
600
+ legend: {
601
+ offsetX: 4,
602
+ position: "right",
603
+ formatter: (seriesName) => {
604
+ if (seriesName === "Internationalized") {
605
+ return \`\${seriesName} (\${i18nPercentage}%)\`;
606
+ }
607
+ return \`\${seriesName} (\${nonI18nPercentage}%)\`;
608
+ },
609
+ },
610
+ plotOptions: {
611
+ bar: {
612
+ borderRadius: 3,
613
+ columnWidth: "85%",
614
+ },
615
+ },
616
+ };
617
+
618
+ (dateTimeChart = new ApexCharts(
619
+ document.querySelector(".datetime-quality .graph"),
620
+ options
621
+ )).render();
622
+ }
623
+ });
624
+ })();
625
+ `;
626
+ exports.default = _default;
@@ -13,7 +13,7 @@ class Reports {
13
13
  static #baseReportPath;
14
14
  static setup() {
15
15
  const rootFolder = _path.default.resolve();
16
- Reports.#baseReportPath = (0, _file.joinPaths)(rootFolder, 'l10nReports', Reports.#dateTime());
16
+ Reports.#baseReportPath = (0, _file.joinPaths)(rootFolder, _config.default.getL10nReportsPath(), Reports.#dateTime());
17
17
  }
18
18
  static reviewedReports(str = null, imgName = null) {
19
19
  return Reports.#generateFullReportPath('reviewed', str, imgName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeesoft/i18n-verify",
3
- "version": "1.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Library to perform I18n verification over Nightwatch or WebdriverIO frameworks",
5
5
  "main": "dist/index.js",
6
6
  "exports": {