@zeesoft/i18n-verify 1.0.0 → 2.0.0

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.
@@ -24,6 +24,22 @@ const renderHtml = ({
24
24
  content="I18n verification report"
25
25
  />
26
26
  <title>I18n Verification Report | ${reportTime}</title>
27
+ <!-- 3rd party dependecies -->
28
+ <link
29
+ rel="stylesheet"
30
+ href="https://cdn.datatables.net/2.0.3/css/dataTables.dataTables.min.css"
31
+ />
32
+ <script
33
+ src="https://code.jquery.com/jquery-3.7.1.slim.min.js"
34
+ integrity="sha256-kmHvs0B+OpCW5GVHUNjv9rOmY0IvSIRcf7zGUDTDQM8="
35
+ crossorigin="anonymous"
36
+ defer
37
+ ></script>
38
+ <script src="https://cdn.jsdelivr.net/npm/apexcharts" defer></script>
39
+ <script
40
+ src="https://cdn.datatables.net/2.0.3/js/dataTables.min.js"
41
+ defer
42
+ ></script>
27
43
  <style>
28
44
  ${style}
29
45
  </style>
@@ -37,7 +53,7 @@ const renderHtml = ({
37
53
  </html>
38
54
  `;
39
55
  exports.renderHtml = renderHtml;
40
- const getBodyData = () => ` <header><div class="logo">zI18n-Verify</div></header>
56
+ const getBodyData = () => `<header><div class="logo">zI18n-Verify</div></header>
41
57
  <main>
42
58
  <div class="sidebar">
43
59
  <ul class="menu" id="menu">
@@ -46,33 +62,96 @@ const getBodyData = () => ` <header><div class="logo">zI18n-Verify</div></header
46
62
  </li>
47
63
  <li class="menu-item has-submenu" data-page="insights">
48
64
  <a href="#" data-page="insights">Insights</a>
49
- <ul class="submenu">
50
- <li class="sub-menu-item" data-locale="en_US">
51
- <a href="#">en_US</a>
52
- </li>
53
- <li class="sub-menu-item" data-locale="fr_CA">
54
- <a href="#">fr_CA</a>
55
- </li>
56
- </ul>
65
+ <ul class="submenu"></ul>
57
66
  </li>
58
67
  </ul>
68
+ <div class="footer"></div>
59
69
  </div>
60
70
  <div class="content-wrapper">
61
71
  <div id="overview" class="content">
62
- <div class="overall-quality">
63
- <span class="title">Overall I18n Quality</span>
72
+ <div class="overall-quality card">
73
+ <span class="title">Overall I18n Coverage</span>
74
+ <div class="section">
75
+ <div class="block">
76
+ <article>
77
+ <p class="desc">
78
+ zI18n-Verify report provides a comprehensive information
79
+ about the I18n and L10n quailty of your application.
80
+ </p>
81
+ <ul class="items">
82
+ <li>
83
+ <h4>Reviewed:</h4>
84
+ <p class="detail">
85
+ Total strings which are captured and processed by
86
+ zI18n-Verify.
87
+ </p>
88
+ </li>
89
+ <li>
90
+ <h4>Internationlized:</h4>
91
+ <p class="detail">
92
+ Different types of value like string, number, date-time
93
+ which are properly Internationalized.
94
+ </p>
95
+ </li>
96
+ <li>
97
+ <h4>Not Internationalized:</h4>
98
+ <p class="detail">
99
+ Values which are not Internationalized. Also includes
100
+ Partially Localized strings and Encoding Issues.
101
+ </p>
102
+ </li>
103
+ <li>
104
+ <h4>Skipped:</h4>
105
+ <p class="detail">
106
+ Values which are skipped from processing because they
107
+ are listed in DNT / Ignored lists or contains Auto
108
+ Ignored pattern / User input pattern.
109
+ </p>
110
+ </li>
111
+ </ul>
112
+ </article>
113
+ </div>
114
+ <div class="block">
115
+ <div class="graph"></div>
116
+ </div>
117
+ </div>
118
+ </div>
119
+ <div class="string-quality card">
120
+ <span class="title">String Coverage</span>
121
+ <div class="graph"></div>
122
+ </div>
123
+ <div class="skipped-items card">
124
+ <span class="title">Skipped Items</span>
125
+ <div class="graph"></div>
126
+ </div>
127
+ <div class="number-quality card">
128
+ <span class="title">Number Coverage</span>
129
+ <div class="graph"></div>
130
+ </div>
131
+ <div class="datetime-quality card">
132
+ <span class="title">DateTime Coverage</span>
133
+ <div class="graph"></div>
64
134
  </div>
65
- <div><span class="title">String Quality</span></div>
66
- <div><span class="title">Number Quality</span></div>
67
- <div><span class="title">DateTime Quality</span></div>
68
135
  </div>
69
136
  <div id="insights" class="content">
70
137
  <div class="cards">
71
- <span class="title">Locale wise info cards</span>
138
+ <span class="title">Locale Quality</span>
139
+ <div class="holder"></div>
72
140
  </div>
73
141
  </div>
74
142
  <div id="locale" class="content">
75
- <div class="string-data"><span class="title">String Data</span></div>
143
+ <span class="title">Locale Quality</span>
144
+ <div class="coverage-info">
145
+ <table class="row-border hover order-column stripe"></table>
146
+ </div>
147
+ <div id="imageViewer" class="image-viewer">
148
+ <span class="close-button" onclick="closeImageViewer()"
149
+ >&times;</span
150
+ >
151
+ <div class="image-container">
152
+ <img id="imageView" src="" alt="Image" />
153
+ </div>
154
+ </div>
76
155
  </div>
77
156
  </div>
78
157
  </main>`;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = (locales, stats, statsByLocale) => ``;
8
+ exports.default = _default;
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = () => `
8
+ //grid view
9
+ (() => {
10
+ document.addEventListener("DOMContentLoaded", function () {
11
+ let table;
12
+ document.querySelectorAll(".sub-menu-item").forEach((menu) => {
13
+ menu.addEventListener("click", (e) => {
14
+ render(e.currentTarget.dataset.locale);
15
+ });
16
+ });
17
+
18
+ const updateTitle = (locale) => {
19
+ document.querySelector(
20
+ "#locale .title"
21
+ ).textContent = \`\${locale} I18n Coverage Details\`;
22
+ };
23
+
24
+ const buildGrid = (_locale) => {
25
+ const data = DataStore.getDataByLocale(_locale);
26
+ $.fn.dataTable.ext.errMode = "none";
27
+ const locale = ["en_US", "fr_FR"];
28
+ const type = [
29
+ "I18n Str",
30
+ "Not I18n Str",
31
+ "Parially Localized",
32
+ "Utranslated",
33
+ "Encoding",
34
+ "DNT",
35
+ "I18n Date",
36
+ "I18n Number",
37
+ "Not I18n DateTime",
38
+ ];
39
+ const testPages = [
40
+ "Welcome-Page",
41
+ "Settings-Page",
42
+ "User-Profile-Page",
43
+ "Dashboard-Page",
44
+ ];
45
+
46
+ const dataSet = Array(100)
47
+ .fill()
48
+ .map((i, v) => [
49
+ \`sample text \${v}\`,
50
+ locale[Math.floor(Math.random() * 2)],
51
+ type[Math.floor(Math.random() * 9)],
52
+ testPages[Math.floor(Math.random() * 3)],
53
+ \`link-\${v}.png\`,
54
+ ]);
55
+ table = new DataTable("#locale .coverage-info table", {
56
+ columns: [
57
+ { title: "String" },
58
+ { title: "Locale" },
59
+ { title: "Type" },
60
+ { title: "Page" },
61
+ { title: "Screenshot" },
62
+ ],
63
+ columnDefs: [
64
+ {
65
+ targets: 4,
66
+ orderable: false,
67
+ searchable: false,
68
+ data: null,
69
+ render: function (data) {
70
+ return \`<a href="#" class="view-screenshot-btn" onclick="openImageViewer('\${data[4]}')">View Screenshot</a>\`;
71
+ },
72
+ },
73
+ ],
74
+ data: dataSet,
75
+ initComplete: function () {
76
+ this.api()
77
+ .columns()
78
+ .every(function () {
79
+ const column = this;
80
+
81
+ if (column[0][0] === 4) {
82
+ return;
83
+ }
84
+
85
+ const select = $(
86
+ '<select class="filter dt-input"><option value="">Filter By</option></select>'
87
+ )
88
+ .appendTo($(column.header()).before())
89
+ .on("change", function () {
90
+ const val = $.fn.dataTable.util.escapeRegex(
91
+ $(this).val()
92
+ );
93
+
94
+ column
95
+ .search(val ? "^" + val + "$" : "", true, false)
96
+ .draw();
97
+ })
98
+ .on("click", function (e) {
99
+ e.stopPropagation();
100
+ e.stopImmediatePropagation();
101
+ });
102
+
103
+ column
104
+ .data()
105
+ .unique()
106
+ .sort()
107
+ .each(function (d, j) {
108
+ select.append(
109
+ '<option value="' + d + '">' + d + "</option>"
110
+ );
111
+ });
112
+ });
113
+ },
114
+ sScrollY:
115
+ document
116
+ .querySelector("#locale .coverage-info")
117
+ .getBoundingClientRect().height - 142,
118
+ pageLength: 25,
119
+ lengthMenu: [10, 25, 50, 100],
120
+ });
121
+
122
+ // Event handler when position select is changed
123
+ $(table.columns(1).header())
124
+ .find("select")
125
+ .on("change", function () {
126
+ var nextSelect = $(table.columns(2).header()).find("select");
127
+ var nextColumn = table.column(2);
128
+ var nextColumnResults = table.column(2, { search: "applied" });
129
+ nextColumn.search("").draw();
130
+ nextSelect.empty();
131
+ nextSelect.append('<option value="">Filter By</option>');
132
+ nextColumnResults
133
+ .data()
134
+ .unique()
135
+ .sort()
136
+ .each(function (d, j) {
137
+ nextSelect.append(
138
+ '<option value="' + d + '">' + d + "</option>"
139
+ );
140
+ });
141
+ });
142
+ };
143
+
144
+ const render = (locale) => {
145
+ updateTitle(locale);
146
+ buildGrid(locale);
147
+ if (table) {
148
+ $($(table.columns(1).header()).find("select")).val(locale);
149
+ table.columns(1).search(locale).draw();
150
+ }
151
+ };
152
+ });
153
+ })();
154
+ `;
155
+ exports.default = _default;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _menuBar = _interopRequireDefault(require("./menuBar.js"));
8
+ var _overview = _interopRequireDefault(require("./overview.js"));
9
+ var _insight = _interopRequireDefault(require("./insight.js"));
10
+ var _grid = _interopRequireDefault(require("./grid.js"));
11
+ var _data = _interopRequireDefault(require("./data.js"));
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ var _default = metaData => `
14
+ ${(0, _data.default)(metaData.locales, metaData.stats, metaData.statsByLocale, metaData.stringData)}
15
+ ${(0, _menuBar.default)()}
16
+ ${(0, _overview.default)()}
17
+ ${(0, _insight.default)()}
18
+ ${(0, _grid.default)()}
19
+ `;
20
+ exports.default = _default;
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = () => `
8
+ //Cards of locales
9
+ (() => {
10
+ document.addEventListener("DOMContentLoaded", function () {
11
+ renderCards();
12
+
13
+ // helper methods to generate cards and its sections
14
+ function createStatSection(data) {
15
+ const isDefaultLocale = false; // dynamically pass
16
+ const holder = document.createElement("div");
17
+ const table = document.createElement("table");
18
+ const tbody = document.createElement("tbody");
19
+ const name = document.createElement("div");
20
+ const tableData = {
21
+ Reviewed: 1000,
22
+ "Internationlized Strings": 600,
23
+ "Not Internationlized Strings": 100,
24
+ "Untranslated Strings": 50,
25
+ "Encoding Issue Strings": 15,
26
+ "DNT Strings": 15,
27
+ "Auto Ignored Strings": 20,
28
+ "Internationlized Numbers": 20,
29
+ "Not Internationlized Numbers": 20,
30
+ "Internationlized Currency": 20,
31
+ "Not Internationlized Currency": 20,
32
+ "Internationlized Date": 20,
33
+ "Not Internationlized Date": 20,
34
+ "Internationlized Time": 20,
35
+ "Not Internationlized Time": 20,
36
+ "Internationlized DateTime": 20,
37
+ "Not Internationlized DateTime": 20,
38
+ };
39
+ const addRow = (name, value) => {
40
+ const row = document.createElement("tr");
41
+
42
+ const col1 = document.createElement("td");
43
+ col1.classList.add("name");
44
+ col1.textContent = name;
45
+
46
+ const col2 = document.createElement("td");
47
+ col2.classList.add("value");
48
+ col2.textContent = value;
49
+
50
+ row.appendChild(col1);
51
+ row.appendChild(col2);
52
+ return row;
53
+ };
54
+
55
+ for (const rowData of Object.entries(tableData)) {
56
+ if (!isDefaultLocale || rowData[0] !== "Untranslated Strings") {
57
+ tbody.appendChild(addRow(rowData[0], rowData[1]));
58
+ }
59
+ }
60
+
61
+ holder.classList.add("stat");
62
+ name.classList.add("name");
63
+ name.textContent = "Summary";
64
+ holder.append(name);
65
+
66
+ table.appendChild(tbody);
67
+ holder.appendChild(table);
68
+ return holder;
69
+ }
70
+
71
+ function createStatusBarSection(data) {
72
+ const holder = document.createElement("div");
73
+ holder.classList.add("status-bar");
74
+
75
+ const generateBarEl = (name, total, current) => {
76
+ current = (current / total) * 100;
77
+ const holder = document.createElement("div");
78
+ holder.classList.add("bar-container");
79
+
80
+ const nameHolder = document.createElement("div");
81
+ nameHolder.classList.add("name");
82
+ nameHolder.textContent = name;
83
+
84
+ const barHolder = document.createElement("div");
85
+ barHolder.classList.add("bar-holder");
86
+
87
+ const bar = document.createElement("div");
88
+ bar.classList.add("bar");
89
+ bar.style.width = \`\${current}%\`;
90
+ bar.textContent = \`\${current}%\`;
91
+
92
+ barHolder.appendChild(bar);
93
+ holder.appendChild(nameHolder);
94
+ holder.appendChild(barHolder);
95
+
96
+ return holder;
97
+ };
98
+
99
+ const isDefaultLocale = false; // should be dynamically passed
100
+ const totalStrings = isDefaultLocale ? 100 : 100; // reviewed - ignore - dnt - autoignore - encoding
101
+ const totalI18nedStr = isDefaultLocale ? 100 : 70;
102
+ const totalLocStr = isDefaultLocale ? 100 : 90;
103
+ const totalI18nedNum = isDefaultLocale ? 100 : 50;
104
+ const totalI18nedDateTime = isDefaultLocale ? 100 : 80;
105
+
106
+ holder.appendChild(
107
+ generateBarEl("String I18n level", totalStrings, totalI18nedStr)
108
+ );
109
+ holder.appendChild(
110
+ generateBarEl("String L10n level", totalStrings, totalLocStr)
111
+ );
112
+ holder.appendChild(
113
+ generateBarEl("Number I18n level", totalStrings, totalI18nedNum)
114
+ );
115
+ holder.appendChild(
116
+ generateBarEl(
117
+ "DateTime I18n level",
118
+ totalStrings,
119
+ totalI18nedDateTime
120
+ )
121
+ );
122
+ return holder;
123
+ }
124
+
125
+ function generateCardContents(data) {
126
+ const cardContent = document.createElement("div");
127
+ cardContent.classList.add("card-content");
128
+
129
+ cardContent.appendChild(createStatusBarSection(data));
130
+ cardContent.appendChild(createStatSection(data));
131
+ return cardContent;
132
+ }
133
+
134
+ function createCardEl(locale, data) {
135
+ const card = document.createElement("div");
136
+ const title = document.createElement("div");
137
+ card.classList.add("card");
138
+ card.dataset.locale = locale;
139
+ title.classList.add("title");
140
+ title.textContent = \`\${locale} details\`;
141
+
142
+ // fire menu selection event on clicking the card
143
+ card.addEventListener("click", () => {
144
+ const previousSelectedSubMenu = document.querySelector(
145
+ '.sub-menu-item.selected'
146
+ );
147
+ if (previousSelectedSubMenu) {
148
+ window.previousSelectedLocale =
149
+ previousSelectedSubMenu.dataset.locale;
150
+ }
151
+
152
+ document
153
+ .querySelector(\`.sub-menu-item[data-locale="\${locale}"]\`)
154
+ .click();
155
+ });
156
+
157
+ card.appendChild(title);
158
+ card.appendChild(generateCardContents(data));
159
+ return card;
160
+ }
161
+
162
+ function renderCards() {
163
+ // read from global variable appData;
164
+ const localeInfo = {
165
+ en_US: {
166
+ total: 1000,
167
+ localized: 700,
168
+ notLocalized: 100,
169
+ untranslated: 50,
170
+ encodingIssue: 20,
171
+ dnt: 15,
172
+ ignored: 10,
173
+ autoIgnored: 5,
174
+ currency: 20,
175
+ number: 20,
176
+ percentage: 15,
177
+ dateTime: 15,
178
+ date: 15,
179
+ time: 15,
180
+ notLocalizedcurrency: 20,
181
+ notLocalizednumber: 20,
182
+ notLocalizedpercentage: 15,
183
+ notLocalizeddateTime: 15,
184
+ notLocalizeddate: 15,
185
+ notLocalizedtime: 15,
186
+ },
187
+ fr_FR: {
188
+ total: 1000,
189
+ localized: 700,
190
+ notLocalized: 100,
191
+ untranslated: 50,
192
+ encodingIssue: 20,
193
+ dnt: 15,
194
+ ignored: 10,
195
+ autoIgnored: 5,
196
+ currency: 20,
197
+ number: 20,
198
+ percentage: 15,
199
+ dateTime: 15,
200
+ date: 15,
201
+ time: 15,
202
+ notLocalizedCurrency: 20,
203
+ notLocalizedNumber: 20,
204
+ notLocalizedPercentage: 15,
205
+ notLocalizedDateTime: 15,
206
+ notLocalizedDate: 15,
207
+ notLocalizedTime: 15,
208
+ },
209
+ };
210
+
211
+ if (Object.keys(localeInfo).length) {
212
+ const cardHolder = document.querySelector(
213
+ "#insights .cards .holder"
214
+ );
215
+ for (const locale in localeInfo) {
216
+ const cardEl = createCardEl(locale, localeInfo[locale]);
217
+ cardHolder.appendChild(cardEl);
218
+ }
219
+ }
220
+ }
221
+ });
222
+ })();
223
+ `;
224
+ exports.default = _default;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = () => `(() => {
8
+ // for sidebar menu
9
+ const loadContent = (section, highlightMenu = false) => {
10
+ if (highlightMenu) {
11
+ document
12
+ .querySelector('li[data-page="overview"]')
13
+ ?.classList.add("selected");
14
+ }
15
+
16
+ const contents = document.querySelectorAll(".content");
17
+ contents.forEach((content) => {
18
+ content.id !== section
19
+ ? content.classList.remove("active")
20
+ : content.classList.add("active");
21
+
22
+ section === "overview" &&
23
+ window.persistOverviewCharts &&
24
+ window.persistOverviewCharts();
25
+
26
+ window.currentPage = section;
27
+ });
28
+ };
29
+
30
+ document.addEventListener("DOMContentLoaded", function () {
31
+ const createMenuItems = (() => {
32
+ const ul = document.querySelector(".sidebar .submenu");
33
+ const createListItems = (locale) => {
34
+ const li = document.createElement("li");
35
+ li.classList.add("sub-menu-item");
36
+ li.dataset.locale = locale;
37
+
38
+ const a = document.createElement("a");
39
+ a.href = "#";
40
+ a.textContent = locale;
41
+
42
+ li.appendChild(a);
43
+ return li;
44
+ };
45
+
46
+ for (const locale of Object.keys(DataStore.getLocalesData())) {
47
+ ul.appendChild(createListItems(locale));
48
+ }
49
+ })();
50
+
51
+ const menuItems = document.querySelectorAll(".menu-item"),
52
+ submenuItems = document.querySelectorAll(".sub-menu-item");
53
+
54
+ menuItems.forEach((item) => {
55
+ item.addEventListener("click", function (event) {
56
+ const selectedMenuItem = document.querySelector(
57
+ ".menu-item.selected"
58
+ ),
59
+ selectedSubmenu = document.querySelector(".submenu.active"),
60
+ page = item.dataset.page;
61
+
62
+ if (selectedMenuItem) {
63
+ selectedMenuItem.classList.remove("selected");
64
+ }
65
+
66
+ if (selectedSubmenu) {
67
+ selectedSubmenu.classList.remove("active");
68
+ }
69
+
70
+ if (item.classList.contains("has-submenu")) {
71
+ event.preventDefault();
72
+ item.classList.add("selected");
73
+ const submenu = item.querySelector(".submenu");
74
+ submenu.classList.add("active");
75
+ } else {
76
+ item.classList.add("selected");
77
+ }
78
+
79
+ if (selectedSubmenu) {
80
+ selectedSubmenu
81
+ .querySelectorAll(".sub-menu-item")
82
+ .forEach((submenuItem) => {
83
+ submenuItem.textContent !== item.textContent &&
84
+ submenuItem.classList.remove("selected");
85
+ });
86
+ }
87
+
88
+ loadContent(page);
89
+ });
90
+
91
+ loadContent("overview", true);
92
+ });
93
+
94
+ submenuItems.forEach((sItem) => {
95
+ sItem.addEventListener("click", function (event) {
96
+ const selectedSubMenuItem = document.querySelector(
97
+ ".sub-menu-item.selected"
98
+ );
99
+ event.preventDefault();
100
+ event.stopPropagation();
101
+
102
+ if (selectedSubMenuItem) {
103
+ selectedSubMenuItem.classList.remove("selected");
104
+ window.previousSelectedLocale =
105
+ selectedSubMenuItem.dataset.locale;
106
+ }
107
+
108
+ sItem.classList.add("selected");
109
+ loadContent("locale");
110
+ });
111
+ });
112
+
113
+ // update footer info
114
+ const footer = document.querySelector(".sidebar .footer");
115
+ footer.textContent = \`${new Date().getFullYear()} @ Zeesoft. All rights reserved.\`;
116
+ });
117
+ })();`;
118
+ exports.default = _default;