@localazy/strapi-plugin 1.0.4 → 1.0.9
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/dist/_chunks/FetchIdentity-4kkW9N7Y.js +981 -0
- package/dist/_chunks/FetchIdentity-BWSQAXt-.mjs +983 -0
- package/dist/_chunks/{LanguagesSelector-CeB7tVcb.mjs → LanguagesSelector-DwAGgpcR.mjs} +4 -2
- package/dist/_chunks/{LanguagesSelector-Bd8VFHib.js → LanguagesSelector-yWC_Yb_S.js} +12 -10
- package/dist/_chunks/{App-NRmSxuW3.js → LocalazyApp-DnaA768k.js} +136 -117
- package/dist/_chunks/{App-CtS6CrNn.mjs → LocalazyApp-zySanVTu.mjs} +32 -13
- package/dist/_chunks/{ContentTransferSetup-CeKXlzw_.mjs → LocalazyContentTransferSetup-C7qVIeix.mjs} +49 -456
- package/dist/_chunks/{ContentTransferSetup-DGs8MZPj.js → LocalazyContentTransferSetup-CeOM6bYA.js} +113 -520
- package/dist/_chunks/{GlobalSettings-rOwd0Y0E.mjs → LocalazyGlobalSettings-QvuLdsLe.mjs} +17 -8
- package/dist/_chunks/{GlobalSettings-CRMPRA3Y.js → LocalazyGlobalSettings-ewETL3oG.js} +61 -52
- package/dist/_chunks/LocalazyPanel-BXVLvFgD.js +83 -0
- package/dist/_chunks/LocalazyPanel-BotUsX-y.mjs +83 -0
- package/dist/_chunks/LocalazyStatusColumn-C81HewMg.mjs +51 -0
- package/dist/_chunks/LocalazyStatusColumn-Dt96YcGQ.js +51 -0
- package/dist/_chunks/{isEqual-CC-cEPwY.mjs → RequireLocalazyAuth-CDuyGCrT.mjs} +22 -1
- package/dist/_chunks/{isEqual-0M0aSdTT.js → RequireLocalazyAuth-CWBWETzC.js} +50 -29
- package/dist/_chunks/_commonjsHelpers-Bc2YnDe1.js +7 -0
- package/dist/_chunks/_commonjsHelpers-DWwsNxpa.mjs +8 -0
- package/dist/_chunks/en-CMWcM0nM.js +10 -0
- package/dist/_chunks/en-RX915msK.mjs +10 -0
- package/dist/_chunks/entry-exclusion-service-BVPICve2.mjs +60 -0
- package/dist/_chunks/entry-exclusion-service-CGV6iOkB.js +60 -0
- package/dist/_chunks/{has-model-changed-gNSOSMBa.js → has-model-changed-DVYRxVhM.js} +33 -32
- package/dist/_chunks/{has-model-changed-DViUIQHk.mjs → has-model-changed-DZL36gWh.mjs} +3 -2
- package/dist/_chunks/i18n-0dV2P-Hm.js +2378 -0
- package/dist/_chunks/i18n-RoETLXdU.mjs +2378 -0
- package/dist/_chunks/index-1he9s_bs.js +430 -0
- package/dist/_chunks/index-BIbKC7-V.mjs +432 -0
- package/dist/_chunks/index-CCxXsn7Z.js +254 -0
- package/dist/_chunks/{set-Cbi1yYuW.js → index-CaY3BYnQ.js} +878 -4379
- package/dist/_chunks/{set-Dnhh_SyE.mjs → index-CgI_aKe_.mjs} +906 -4408
- package/dist/_chunks/index-DsrYI6aB.mjs +231 -0
- package/dist/_chunks/initReactI18next-B0H8_DlW.js +60 -0
- package/dist/_chunks/initReactI18next-MHHxeg_9.mjs +61 -0
- package/dist/_chunks/{index-Dj68Ixl2.mjs → strapi-api-base-BE8VMlaA.js} +7 -234
- package/dist/_chunks/{index-Bbwk3kp3.js → strapi-api-base-DjeKGUw7.mjs} +15 -242
- package/dist/_chunks/useTranslation-BdIl-aLe.js +188 -0
- package/dist/_chunks/useTranslation-CZQ4lU1m.mjs +189 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/LocalazyPanel.d.ts +4 -0
- package/dist/admin/src/components/LocalazyStatusColumn.d.ts +3 -0
- package/dist/admin/src/components/RequireLocalazyAuth.d.ts +6 -0
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/modules/entry-exclusion/services/entry-exclusion-service.d.ts +18 -0
- package/dist/admin/src/modules/plugin-settings/locale/en.d.ts +8 -0
- package/dist/admin/src/pages/LocalazyApp.d.ts +2 -0
- package/dist/admin/src/pages/LocalazyContentTransferSetup.d.ts +2 -0
- package/dist/admin/src/pages/LocalazyGlobalSettings.d.ts +2 -0
- package/dist/server/index.js +202 -35
- package/dist/server/index.mjs +202 -35
- package/dist/server/src/controllers/entry-exclusion-controller.d.ts +21 -0
- package/dist/server/src/controllers/index.d.ts +7 -0
- package/dist/server/src/core/index.d.ts +6 -0
- package/dist/server/src/index.d.ts +15 -0
- package/dist/server/src/routes/entry-exclusion-routes.d.ts +9 -0
- package/dist/server/src/services/entry-exclusion-service.d.ts +23 -0
- package/dist/server/src/services/index.d.ts +8 -0
- package/package.json +2 -2
- package/dist/_chunks/en-BTf8goGM.mjs +0 -8
- package/dist/_chunks/en-CRtsEFtl.js +0 -8
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { createElement, isValidElement, cloneElement, Children, Fragment, useContext } from "react";
|
|
2
|
+
import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-DWwsNxpa.mjs";
|
|
3
|
+
import { w as warnOnce, i as isString, a as warn, b as isObject, I as I18nContext } from "./useTranslation-CZQ4lU1m.mjs";
|
|
4
|
+
import { u } from "./useTranslation-CZQ4lU1m.mjs";
|
|
5
|
+
import { g as getI18n, a as getDefaults } from "./initReactI18next-MHHxeg_9.mjs";
|
|
6
|
+
import { i, s, b } from "./initReactI18next-MHHxeg_9.mjs";
|
|
7
|
+
var voidElements = {
|
|
8
|
+
"area": true,
|
|
9
|
+
"base": true,
|
|
10
|
+
"br": true,
|
|
11
|
+
"col": true,
|
|
12
|
+
"embed": true,
|
|
13
|
+
"hr": true,
|
|
14
|
+
"img": true,
|
|
15
|
+
"input": true,
|
|
16
|
+
"link": true,
|
|
17
|
+
"meta": true,
|
|
18
|
+
"param": true,
|
|
19
|
+
"source": true,
|
|
20
|
+
"track": true,
|
|
21
|
+
"wbr": true
|
|
22
|
+
};
|
|
23
|
+
const e = /* @__PURE__ */ getDefaultExportFromCjs(voidElements);
|
|
24
|
+
var t = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;
|
|
25
|
+
function n(n2) {
|
|
26
|
+
var r2 = { type: "tag", name: "", voidElement: false, attrs: {}, children: [] }, i3 = n2.match(/<\/?([^\s]+?)[/\s>]/);
|
|
27
|
+
if (i3 && (r2.name = i3[1], (e[i3[1]] || "/" === n2.charAt(n2.length - 2)) && (r2.voidElement = true), r2.name.startsWith("!--"))) {
|
|
28
|
+
var s3 = n2.indexOf("-->");
|
|
29
|
+
return { type: "comment", comment: -1 !== s3 ? n2.slice(4, s3) : "" };
|
|
30
|
+
}
|
|
31
|
+
for (var a2 = new RegExp(t), c2 = null; null !== (c2 = a2.exec(n2)); ) if (c2[0].trim()) if (c2[1]) {
|
|
32
|
+
var o = c2[1].trim(), l = [o, ""];
|
|
33
|
+
o.indexOf("=") > -1 && (l = o.split("=")), r2.attrs[l[0]] = l[1], a2.lastIndex--;
|
|
34
|
+
} else c2[2] && (r2.attrs[c2[2]] = c2[3].trim().substring(1, c2[3].length - 1));
|
|
35
|
+
return r2;
|
|
36
|
+
}
|
|
37
|
+
var r = /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g, i2 = /^\s*$/, s2 = /* @__PURE__ */ Object.create(null);
|
|
38
|
+
function a(e2, t2) {
|
|
39
|
+
switch (t2.type) {
|
|
40
|
+
case "text":
|
|
41
|
+
return e2 + t2.content;
|
|
42
|
+
case "tag":
|
|
43
|
+
return e2 += "<" + t2.name + (t2.attrs ? function(e3) {
|
|
44
|
+
var t3 = [];
|
|
45
|
+
for (var n2 in e3) t3.push(n2 + '="' + e3[n2] + '"');
|
|
46
|
+
return t3.length ? " " + t3.join(" ") : "";
|
|
47
|
+
}(t2.attrs) : "") + (t2.voidElement ? "/>" : ">"), t2.voidElement ? e2 : e2 + t2.children.reduce(a, "") + "</" + t2.name + ">";
|
|
48
|
+
case "comment":
|
|
49
|
+
return e2 + "<!--" + t2.comment + "-->";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
var c = { parse: function(e2, t2) {
|
|
53
|
+
t2 || (t2 = {}), t2.components || (t2.components = s2);
|
|
54
|
+
var a2, c2 = [], o = [], l = -1, m = false;
|
|
55
|
+
if (0 !== e2.indexOf("<")) {
|
|
56
|
+
var u2 = e2.indexOf("<");
|
|
57
|
+
c2.push({ type: "text", content: -1 === u2 ? e2 : e2.substring(0, u2) });
|
|
58
|
+
}
|
|
59
|
+
return e2.replace(r, function(r2, s3) {
|
|
60
|
+
if (m) {
|
|
61
|
+
if (r2 !== "</" + a2.name + ">") return;
|
|
62
|
+
m = false;
|
|
63
|
+
}
|
|
64
|
+
var u3, f = "/" !== r2.charAt(1), h = r2.startsWith("<!--"), p = s3 + r2.length, d = e2.charAt(p);
|
|
65
|
+
if (h) {
|
|
66
|
+
var v = n(r2);
|
|
67
|
+
return l < 0 ? (c2.push(v), c2) : ((u3 = o[l]).children.push(v), c2);
|
|
68
|
+
}
|
|
69
|
+
if (f && (l++, "tag" === (a2 = n(r2)).type && t2.components[a2.name] && (a2.type = "component", m = true), a2.voidElement || m || !d || "<" === d || a2.children.push({ type: "text", content: e2.slice(p, e2.indexOf("<", p)) }), 0 === l && c2.push(a2), (u3 = o[l - 1]) && u3.children.push(a2), o[l] = a2), (!f || a2.voidElement) && (l > -1 && (a2.voidElement || a2.name === r2.slice(2, -1)) && (l--, a2 = -1 === l ? c2 : o[l]), !m && "<" !== d && d)) {
|
|
70
|
+
u3 = -1 === l ? c2 : o[l].children;
|
|
71
|
+
var x = e2.indexOf("<", p), g = e2.slice(p, -1 === x ? void 0 : x);
|
|
72
|
+
i2.test(g) && (g = " "), (x > -1 && l + u3.length >= 0 || " " !== g) && u3.push({ type: "text", content: g });
|
|
73
|
+
}
|
|
74
|
+
}), c2;
|
|
75
|
+
}, stringify: function(e2) {
|
|
76
|
+
return e2.reduce(function(e3, t2) {
|
|
77
|
+
return e3 + a("", t2);
|
|
78
|
+
}, "");
|
|
79
|
+
} };
|
|
80
|
+
const hasChildren = (node, checkLength) => {
|
|
81
|
+
if (!node) return false;
|
|
82
|
+
const base = node.props?.children ?? node.children;
|
|
83
|
+
if (checkLength) return base.length > 0;
|
|
84
|
+
return !!base;
|
|
85
|
+
};
|
|
86
|
+
const getChildren = (node) => {
|
|
87
|
+
if (!node) return [];
|
|
88
|
+
const children = node.props?.children ?? node.children;
|
|
89
|
+
return node.props?.i18nIsDynamicList ? getAsArray(children) : children;
|
|
90
|
+
};
|
|
91
|
+
const hasValidReactChildren = (children) => Array.isArray(children) && children.every(isValidElement);
|
|
92
|
+
const getAsArray = (data) => Array.isArray(data) ? data : [data];
|
|
93
|
+
const mergeProps = (source, target) => {
|
|
94
|
+
const newTarget = {
|
|
95
|
+
...target
|
|
96
|
+
};
|
|
97
|
+
newTarget.props = Object.assign(source.props, target.props);
|
|
98
|
+
return newTarget;
|
|
99
|
+
};
|
|
100
|
+
const nodesToString = (children, i18nOptions, i18n, i18nKey) => {
|
|
101
|
+
if (!children) return "";
|
|
102
|
+
let stringNode = "";
|
|
103
|
+
const childrenArray = getAsArray(children);
|
|
104
|
+
const keepArray = i18nOptions?.transSupportBasicHtmlNodes ? i18nOptions.transKeepBasicHtmlNodesFor ?? [] : [];
|
|
105
|
+
childrenArray.forEach((child, childIndex) => {
|
|
106
|
+
if (isString(child)) {
|
|
107
|
+
stringNode += `${child}`;
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (isValidElement(child)) {
|
|
111
|
+
const {
|
|
112
|
+
props,
|
|
113
|
+
type
|
|
114
|
+
} = child;
|
|
115
|
+
const childPropsCount = Object.keys(props).length;
|
|
116
|
+
const shouldKeepChild = keepArray.indexOf(type) > -1;
|
|
117
|
+
const childChildren = props.children;
|
|
118
|
+
if (!childChildren && shouldKeepChild && !childPropsCount) {
|
|
119
|
+
stringNode += `<${type}/>`;
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (!childChildren && (!shouldKeepChild || childPropsCount) || props.i18nIsDynamicList) {
|
|
123
|
+
stringNode += `<${childIndex}></${childIndex}>`;
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (shouldKeepChild && childPropsCount === 1 && isString(childChildren)) {
|
|
127
|
+
stringNode += `<${type}>${childChildren}</${type}>`;
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const content = nodesToString(childChildren, i18nOptions, i18n, i18nKey);
|
|
131
|
+
stringNode += `<${childIndex}>${content}</${childIndex}>`;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (child === null) {
|
|
135
|
+
warn(i18n, "TRANS_NULL_VALUE", `Passed in a null value as child`, {
|
|
136
|
+
i18nKey
|
|
137
|
+
});
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (isObject(child)) {
|
|
141
|
+
const {
|
|
142
|
+
format,
|
|
143
|
+
...clone
|
|
144
|
+
} = child;
|
|
145
|
+
const keys = Object.keys(clone);
|
|
146
|
+
if (keys.length === 1) {
|
|
147
|
+
const value = format ? `${keys[0]}, ${format}` : keys[0];
|
|
148
|
+
stringNode += `{{${value}}}`;
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
warn(i18n, "TRANS_INVALID_OBJ", `Invalid child - Object should only have keys {{ value, format }} (format is optional).`, {
|
|
152
|
+
i18nKey,
|
|
153
|
+
child
|
|
154
|
+
});
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
warn(i18n, "TRANS_INVALID_VAR", `Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`, {
|
|
158
|
+
i18nKey,
|
|
159
|
+
child
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
return stringNode;
|
|
163
|
+
};
|
|
164
|
+
const renderNodes = (children, targetString, i18n, i18nOptions, combinedTOpts, shouldUnescape) => {
|
|
165
|
+
if (targetString === "") return [];
|
|
166
|
+
const keepArray = i18nOptions.transKeepBasicHtmlNodesFor || [];
|
|
167
|
+
const emptyChildrenButNeedsHandling = targetString && new RegExp(keepArray.map((keep) => `<${keep}`).join("|")).test(targetString);
|
|
168
|
+
if (!children && !emptyChildrenButNeedsHandling && !shouldUnescape) return [targetString];
|
|
169
|
+
const data = {};
|
|
170
|
+
const getData = (childs) => {
|
|
171
|
+
const childrenArray = getAsArray(childs);
|
|
172
|
+
childrenArray.forEach((child) => {
|
|
173
|
+
if (isString(child)) return;
|
|
174
|
+
if (hasChildren(child)) getData(getChildren(child));
|
|
175
|
+
else if (isObject(child) && !isValidElement(child)) Object.assign(data, child);
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
getData(children);
|
|
179
|
+
const ast = c.parse(`<0>${targetString}</0>`);
|
|
180
|
+
const opts = {
|
|
181
|
+
...data,
|
|
182
|
+
...combinedTOpts
|
|
183
|
+
};
|
|
184
|
+
const renderInner = (child, node, rootReactNode) => {
|
|
185
|
+
const childs = getChildren(child);
|
|
186
|
+
const mappedChildren = mapAST(childs, node.children, rootReactNode);
|
|
187
|
+
return hasValidReactChildren(childs) && mappedChildren.length === 0 || child.props?.i18nIsDynamicList ? childs : mappedChildren;
|
|
188
|
+
};
|
|
189
|
+
const pushTranslatedJSX = (child, inner, mem, i3, isVoid) => {
|
|
190
|
+
if (child.dummy) {
|
|
191
|
+
child.children = inner;
|
|
192
|
+
mem.push(cloneElement(child, {
|
|
193
|
+
key: i3
|
|
194
|
+
}, isVoid ? void 0 : inner));
|
|
195
|
+
} else {
|
|
196
|
+
mem.push(...Children.map([child], (c2) => {
|
|
197
|
+
const props = {
|
|
198
|
+
...c2.props
|
|
199
|
+
};
|
|
200
|
+
delete props.i18nIsDynamicList;
|
|
201
|
+
return createElement(c2.type, {
|
|
202
|
+
...props,
|
|
203
|
+
key: i3,
|
|
204
|
+
ref: c2.ref
|
|
205
|
+
}, isVoid ? null : inner);
|
|
206
|
+
}));
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
const mapAST = (reactNode, astNode, rootReactNode) => {
|
|
210
|
+
const reactNodes = getAsArray(reactNode);
|
|
211
|
+
const astNodes = getAsArray(astNode);
|
|
212
|
+
return astNodes.reduce((mem, node, i3) => {
|
|
213
|
+
const translationContent = node.children?.[0]?.content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language);
|
|
214
|
+
if (node.type === "tag") {
|
|
215
|
+
let tmp = reactNodes[parseInt(node.name, 10)];
|
|
216
|
+
if (rootReactNode.length === 1 && !tmp) tmp = rootReactNode[0][node.name];
|
|
217
|
+
if (!tmp) tmp = {};
|
|
218
|
+
const child = Object.keys(node.attrs).length !== 0 ? mergeProps({
|
|
219
|
+
props: node.attrs
|
|
220
|
+
}, tmp) : tmp;
|
|
221
|
+
const isElement = isValidElement(child);
|
|
222
|
+
const isValidTranslationWithChildren = isElement && hasChildren(node, true) && !node.voidElement;
|
|
223
|
+
const isEmptyTransWithHTML = emptyChildrenButNeedsHandling && isObject(child) && child.dummy && !isElement;
|
|
224
|
+
const isKnownComponent = isObject(children) && Object.hasOwnProperty.call(children, node.name);
|
|
225
|
+
if (isString(child)) {
|
|
226
|
+
const value = i18n.services.interpolator.interpolate(child, opts, i18n.language);
|
|
227
|
+
mem.push(value);
|
|
228
|
+
} else if (hasChildren(child) || isValidTranslationWithChildren) {
|
|
229
|
+
const inner = renderInner(child, node, rootReactNode);
|
|
230
|
+
pushTranslatedJSX(child, inner, mem, i3);
|
|
231
|
+
} else if (isEmptyTransWithHTML) {
|
|
232
|
+
const inner = mapAST(reactNodes, node.children, rootReactNode);
|
|
233
|
+
pushTranslatedJSX(child, inner, mem, i3);
|
|
234
|
+
} else if (Number.isNaN(parseFloat(node.name))) {
|
|
235
|
+
if (isKnownComponent) {
|
|
236
|
+
const inner = renderInner(child, node, rootReactNode);
|
|
237
|
+
pushTranslatedJSX(child, inner, mem, i3, node.voidElement);
|
|
238
|
+
} else if (i18nOptions.transSupportBasicHtmlNodes && keepArray.indexOf(node.name) > -1) {
|
|
239
|
+
if (node.voidElement) {
|
|
240
|
+
mem.push(createElement(node.name, {
|
|
241
|
+
key: `${node.name}-${i3}`
|
|
242
|
+
}));
|
|
243
|
+
} else {
|
|
244
|
+
const inner = mapAST(reactNodes, node.children, rootReactNode);
|
|
245
|
+
mem.push(createElement(node.name, {
|
|
246
|
+
key: `${node.name}-${i3}`
|
|
247
|
+
}, inner));
|
|
248
|
+
}
|
|
249
|
+
} else if (node.voidElement) {
|
|
250
|
+
mem.push(`<${node.name} />`);
|
|
251
|
+
} else {
|
|
252
|
+
const inner = mapAST(reactNodes, node.children, rootReactNode);
|
|
253
|
+
mem.push(`<${node.name}>${inner}</${node.name}>`);
|
|
254
|
+
}
|
|
255
|
+
} else if (isObject(child) && !isElement) {
|
|
256
|
+
const content = node.children[0] ? translationContent : null;
|
|
257
|
+
if (content) mem.push(content);
|
|
258
|
+
} else {
|
|
259
|
+
pushTranslatedJSX(child, translationContent, mem, i3, node.children.length !== 1 || !translationContent);
|
|
260
|
+
}
|
|
261
|
+
} else if (node.type === "text") {
|
|
262
|
+
const wrapTextNodes = i18nOptions.transWrapTextNodes;
|
|
263
|
+
const content = shouldUnescape ? i18nOptions.unescape(i18n.services.interpolator.interpolate(node.content, opts, i18n.language)) : i18n.services.interpolator.interpolate(node.content, opts, i18n.language);
|
|
264
|
+
if (wrapTextNodes) {
|
|
265
|
+
mem.push(createElement(wrapTextNodes, {
|
|
266
|
+
key: `${node.name}-${i3}`
|
|
267
|
+
}, content));
|
|
268
|
+
} else {
|
|
269
|
+
mem.push(content);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return mem;
|
|
273
|
+
}, []);
|
|
274
|
+
};
|
|
275
|
+
const result = mapAST([{
|
|
276
|
+
dummy: true,
|
|
277
|
+
children: children || []
|
|
278
|
+
}], ast, getAsArray(children || []));
|
|
279
|
+
return getChildren(result[0]);
|
|
280
|
+
};
|
|
281
|
+
const fixComponentProps = (component, index, translation) => {
|
|
282
|
+
const componentKey = component.key || index;
|
|
283
|
+
const comp = cloneElement(component, {
|
|
284
|
+
key: componentKey
|
|
285
|
+
});
|
|
286
|
+
if (!comp.props || !comp.props.children || translation.indexOf(`${index}/>`) < 0 && translation.indexOf(`${index} />`) < 0) {
|
|
287
|
+
return comp;
|
|
288
|
+
}
|
|
289
|
+
function Componentized() {
|
|
290
|
+
return createElement(Fragment, null, comp);
|
|
291
|
+
}
|
|
292
|
+
return createElement(Componentized);
|
|
293
|
+
};
|
|
294
|
+
const generateArrayComponents = (components, translation) => components.map((c2, index) => fixComponentProps(c2, index, translation));
|
|
295
|
+
const generateObjectComponents = (components, translation) => {
|
|
296
|
+
const componentMap = {};
|
|
297
|
+
Object.keys(components).forEach((c2) => {
|
|
298
|
+
Object.assign(componentMap, {
|
|
299
|
+
[c2]: fixComponentProps(components[c2], c2, translation)
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
return componentMap;
|
|
303
|
+
};
|
|
304
|
+
const generateComponents = (components, translation, i18n, i18nKey) => {
|
|
305
|
+
if (!components) return null;
|
|
306
|
+
if (Array.isArray(components)) {
|
|
307
|
+
return generateArrayComponents(components, translation);
|
|
308
|
+
}
|
|
309
|
+
if (isObject(components)) {
|
|
310
|
+
return generateObjectComponents(components, translation);
|
|
311
|
+
}
|
|
312
|
+
warnOnce(i18n, "TRANS_INVALID_COMPONENTS", `<Trans /> "components" prop expects an object or array`, {
|
|
313
|
+
i18nKey
|
|
314
|
+
});
|
|
315
|
+
return null;
|
|
316
|
+
};
|
|
317
|
+
function Trans$1({
|
|
318
|
+
children,
|
|
319
|
+
count,
|
|
320
|
+
parent,
|
|
321
|
+
i18nKey,
|
|
322
|
+
context,
|
|
323
|
+
tOptions = {},
|
|
324
|
+
values,
|
|
325
|
+
defaults,
|
|
326
|
+
components,
|
|
327
|
+
ns,
|
|
328
|
+
i18n: i18nFromProps,
|
|
329
|
+
t: tFromProps,
|
|
330
|
+
shouldUnescape,
|
|
331
|
+
...additionalProps
|
|
332
|
+
}) {
|
|
333
|
+
const i18n = i18nFromProps || getI18n();
|
|
334
|
+
if (!i18n) {
|
|
335
|
+
warnOnce(i18n, "NO_I18NEXT_INSTANCE", `Trans: You need to pass in an i18next instance using i18nextReactModule`, {
|
|
336
|
+
i18nKey
|
|
337
|
+
});
|
|
338
|
+
return children;
|
|
339
|
+
}
|
|
340
|
+
const t2 = tFromProps || i18n.t.bind(i18n) || ((k) => k);
|
|
341
|
+
const reactI18nextOptions = {
|
|
342
|
+
...getDefaults(),
|
|
343
|
+
...i18n.options?.react
|
|
344
|
+
};
|
|
345
|
+
let namespaces = ns || t2.ns || i18n.options?.defaultNS;
|
|
346
|
+
namespaces = isString(namespaces) ? [namespaces] : namespaces || ["translation"];
|
|
347
|
+
const nodeAsString = nodesToString(children, reactI18nextOptions, i18n, i18nKey);
|
|
348
|
+
const defaultValue = defaults || nodeAsString || reactI18nextOptions.transEmptyNodeValue || i18nKey;
|
|
349
|
+
const {
|
|
350
|
+
hashTransKey
|
|
351
|
+
} = reactI18nextOptions;
|
|
352
|
+
const key = i18nKey || (hashTransKey ? hashTransKey(nodeAsString || defaultValue) : nodeAsString || defaultValue);
|
|
353
|
+
if (i18n.options?.interpolation?.defaultVariables) {
|
|
354
|
+
values = values && Object.keys(values).length > 0 ? {
|
|
355
|
+
...values,
|
|
356
|
+
...i18n.options.interpolation.defaultVariables
|
|
357
|
+
} : {
|
|
358
|
+
...i18n.options.interpolation.defaultVariables
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
const interpolationOverride = values || count !== void 0 && !i18n.options?.interpolation?.alwaysFormat || !children ? tOptions.interpolation : {
|
|
362
|
+
interpolation: {
|
|
363
|
+
...tOptions.interpolation,
|
|
364
|
+
prefix: "#$?",
|
|
365
|
+
suffix: "?$#"
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
const combinedTOpts = {
|
|
369
|
+
...tOptions,
|
|
370
|
+
context: context || tOptions.context,
|
|
371
|
+
count,
|
|
372
|
+
...values,
|
|
373
|
+
...interpolationOverride,
|
|
374
|
+
defaultValue,
|
|
375
|
+
ns: namespaces
|
|
376
|
+
};
|
|
377
|
+
const translation = key ? t2(key, combinedTOpts) : defaultValue;
|
|
378
|
+
const generatedComponents = generateComponents(components, translation, i18n, i18nKey);
|
|
379
|
+
const content = renderNodes(generatedComponents || children, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape);
|
|
380
|
+
const useAsParent = parent ?? reactI18nextOptions.defaultTransParent;
|
|
381
|
+
return useAsParent ? createElement(useAsParent, additionalProps, content) : content;
|
|
382
|
+
}
|
|
383
|
+
function Trans({
|
|
384
|
+
children,
|
|
385
|
+
count,
|
|
386
|
+
parent,
|
|
387
|
+
i18nKey,
|
|
388
|
+
context,
|
|
389
|
+
tOptions = {},
|
|
390
|
+
values,
|
|
391
|
+
defaults,
|
|
392
|
+
components,
|
|
393
|
+
ns,
|
|
394
|
+
i18n: i18nFromProps,
|
|
395
|
+
t: tFromProps,
|
|
396
|
+
shouldUnescape,
|
|
397
|
+
...additionalProps
|
|
398
|
+
}) {
|
|
399
|
+
const {
|
|
400
|
+
i18n: i18nFromContext,
|
|
401
|
+
defaultNS: defaultNSFromContext
|
|
402
|
+
} = useContext(I18nContext) || {};
|
|
403
|
+
const i18n = i18nFromProps || i18nFromContext || getI18n();
|
|
404
|
+
const t2 = tFromProps || i18n?.t.bind(i18n);
|
|
405
|
+
return Trans$1({
|
|
406
|
+
children,
|
|
407
|
+
count,
|
|
408
|
+
parent,
|
|
409
|
+
i18nKey,
|
|
410
|
+
context,
|
|
411
|
+
tOptions,
|
|
412
|
+
values,
|
|
413
|
+
defaults,
|
|
414
|
+
components,
|
|
415
|
+
ns: ns || t2?.ns || defaultNSFromContext || i18n?.options?.defaultNS,
|
|
416
|
+
i18n,
|
|
417
|
+
t: tFromProps,
|
|
418
|
+
shouldUnescape,
|
|
419
|
+
...additionalProps
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
export {
|
|
423
|
+
I18nContext,
|
|
424
|
+
Trans,
|
|
425
|
+
Trans$1 as TransWithoutContext,
|
|
426
|
+
getDefaults,
|
|
427
|
+
getI18n,
|
|
428
|
+
i as initReactI18next,
|
|
429
|
+
s as setDefaults,
|
|
430
|
+
b as setI18n,
|
|
431
|
+
u as useTranslation
|
|
432
|
+
};
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
const React = require("react");
|
|
25
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
26
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
27
|
+
const React__default = /* @__PURE__ */ _interopDefault(React);
|
|
28
|
+
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
29
|
+
const v = glob[path];
|
|
30
|
+
if (v) {
|
|
31
|
+
return typeof v === "function" ? v() : Promise.resolve(v);
|
|
32
|
+
}
|
|
33
|
+
return new Promise((_, reject) => {
|
|
34
|
+
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
|
35
|
+
reject.bind(
|
|
36
|
+
null,
|
|
37
|
+
new Error(
|
|
38
|
+
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
|
39
|
+
)
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const strapi = {
|
|
45
|
+
name: "localazy"
|
|
46
|
+
};
|
|
47
|
+
const pluginPkg = {
|
|
48
|
+
strapi
|
|
49
|
+
};
|
|
50
|
+
const PLUGIN_ID = pluginPkg.strapi.name;
|
|
51
|
+
const Initializer = ({ setPlugin }) => {
|
|
52
|
+
const ref = React.useRef(setPlugin);
|
|
53
|
+
React.useEffect(() => {
|
|
54
|
+
ref.current(PLUGIN_ID);
|
|
55
|
+
}, []);
|
|
56
|
+
return null;
|
|
57
|
+
};
|
|
58
|
+
const Localazy = () => {
|
|
59
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", fill: "#8e8ea9", children: [
|
|
60
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M16.4517 2.56643L16.3247 2.87501L15.5632 4.67576H7.49071C7.18595 4.67576 6.98278 4.98434 7.1013 5.26333L9.05259 9.91314C9.12031 10.0695 9.27269 10.171 9.442 10.171H12.6211C12.9216 10.171 13.1247 10.4753 13.0147 10.7501L12.8919 11.046L12.1353 12.8468H10.9192C10.6187 12.8468 10.4113 13.1553 10.5298 13.4343L13.8229 21.2925C13.9626 21.6265 13.7171 21.9942 13.353 21.9942H11.3256C11.1224 21.9942 10.9362 21.8716 10.8557 21.6814L3.1056 3.17091C2.8728 2.61293 3.27915 2 3.88443 2H16.0538C16.3501 2 16.5533 2.29167 16.4517 2.56643Z" }),
|
|
61
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M17.2937 13.5315L21.0354 4.63345C21.2724 4.07548 20.8619 3.45832 20.2566 3.46255L17.2267 3.46255L16.4794 5.23793C16.4794 5.24638 16.4752 5.25484 16.4709 5.26329L16.4709 5.26329L16.3482 5.55074C16.2297 5.82973 16.4371 6.1383 16.7376 6.1383H16.8069C17.1074 6.1383 17.3148 6.44688 17.1963 6.72587L15.2408 11.3757C15.1773 11.5321 15.0207 11.6335 14.8514 11.6335H13.7902L12.9112 13.7217C12.7927 14.0007 13.0001 14.3093 13.3006 14.3093H16.1212C16.6334 14.3093 17.0947 14.0007 17.2937 13.5315Z" })
|
|
62
|
+
] });
|
|
63
|
+
};
|
|
64
|
+
const index = {
|
|
65
|
+
register(app) {
|
|
66
|
+
addMenuLink(app);
|
|
67
|
+
addSettingsSection(app);
|
|
68
|
+
addPlugin(app);
|
|
69
|
+
},
|
|
70
|
+
async registerTrads({ locales }) {
|
|
71
|
+
return Promise.all(
|
|
72
|
+
locales.map(async (locale) => {
|
|
73
|
+
try {
|
|
74
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("./en-CMWcM0nM.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-C8Qw4iPZ.js")) }), `./translations/${locale}.json`, 3);
|
|
75
|
+
return { data, locale };
|
|
76
|
+
} catch {
|
|
77
|
+
return { data: {}, locale };
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
},
|
|
82
|
+
async bootstrap(app) {
|
|
83
|
+
try {
|
|
84
|
+
const contentManagerPlugin = app.getPlugin("content-manager");
|
|
85
|
+
if (contentManagerPlugin?.apis?.addEditViewSidePanel) {
|
|
86
|
+
const { default: LocalazyPanel } = await Promise.resolve().then(() => require("./LocalazyPanel-BXVLvFgD.js"));
|
|
87
|
+
const apis = contentManagerPlugin.apis;
|
|
88
|
+
apis.addEditViewSidePanel([LocalazyPanel]);
|
|
89
|
+
} else {
|
|
90
|
+
console.warn('Localazy Plugin: Content Manager "addEditViewSidePanel" API not available');
|
|
91
|
+
}
|
|
92
|
+
const { default: LocalazyStatusColumn } = await Promise.resolve().then(() => require("./LocalazyStatusColumn-Dt96YcGQ.js"));
|
|
93
|
+
app.registerHook("Admin/CM/pages/ListView/inject-column-in-table", (params) => {
|
|
94
|
+
try {
|
|
95
|
+
console.log("Localazy: Hook called with params:", params);
|
|
96
|
+
const { displayedHeaders, layout } = params;
|
|
97
|
+
if (!Array.isArray(displayedHeaders)) {
|
|
98
|
+
return params;
|
|
99
|
+
}
|
|
100
|
+
const localazyStatusColumn = {
|
|
101
|
+
name: "localazy_status",
|
|
102
|
+
label: "Localazy Status",
|
|
103
|
+
searchable: false,
|
|
104
|
+
sortable: false,
|
|
105
|
+
attribute: { type: "custom" },
|
|
106
|
+
cellFormatter: (data, header, context) => {
|
|
107
|
+
return React__default.default.createElement(LocalazyStatusColumn, {
|
|
108
|
+
data,
|
|
109
|
+
model: context?.model || ""
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const updatedHeaders = [...displayedHeaders, localazyStatusColumn];
|
|
114
|
+
return {
|
|
115
|
+
displayedHeaders: updatedHeaders,
|
|
116
|
+
layout
|
|
117
|
+
};
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error("Localazy: Error in hook:", error);
|
|
120
|
+
return params;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
if (contentManagerPlugin?.apis?.addBulkAction) {
|
|
124
|
+
const { useNotification } = await import("@strapi/strapi/admin");
|
|
125
|
+
await Promise.resolve().then(() => require("./i18n-0dV2P-Hm.js"));
|
|
126
|
+
const { useTranslation } = await Promise.resolve().then(() => require("./index-1he9s_bs.js"));
|
|
127
|
+
const ExcludeFromTranslationAction = (props) => {
|
|
128
|
+
const { documents, model } = props;
|
|
129
|
+
const { toggleNotification } = useNotification();
|
|
130
|
+
const { t } = useTranslation();
|
|
131
|
+
return {
|
|
132
|
+
label: t("plugin_settings.bulk_action_exclude_from_translation"),
|
|
133
|
+
variant: "secondary",
|
|
134
|
+
onClick: async () => {
|
|
135
|
+
try {
|
|
136
|
+
toggleNotification({
|
|
137
|
+
type: "info",
|
|
138
|
+
message: t("plugin_settings.bulk_action_updating_entries")
|
|
139
|
+
});
|
|
140
|
+
const { default: EntryExclusionService } = await Promise.resolve().then(() => require("./entry-exclusion-service-CGV6iOkB.js"));
|
|
141
|
+
const documentIds = documents.map((doc) => doc.documentId);
|
|
142
|
+
await EntryExclusionService.setMultipleEntriesExclusion(model, documentIds, true);
|
|
143
|
+
toggleNotification({
|
|
144
|
+
type: "success",
|
|
145
|
+
message: t("plugin_settings.bulk_action_success_message"),
|
|
146
|
+
timeout: 5e3
|
|
147
|
+
});
|
|
148
|
+
} catch (error) {
|
|
149
|
+
console.error("Failed to exclude entries from translation:", error);
|
|
150
|
+
toggleNotification({
|
|
151
|
+
type: "danger",
|
|
152
|
+
message: t("plugin_settings.bulk_action_failed_message")
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
ExcludeFromTranslationAction.type = "exclude-translation";
|
|
159
|
+
const IncludeToTranslationAction = ({ documents, model }) => {
|
|
160
|
+
const { toggleNotification } = useNotification();
|
|
161
|
+
const { t } = useTranslation();
|
|
162
|
+
return {
|
|
163
|
+
label: t("plugin_settings.bulk_action_include_to_translation"),
|
|
164
|
+
variant: "secondary",
|
|
165
|
+
onClick: async () => {
|
|
166
|
+
try {
|
|
167
|
+
toggleNotification({
|
|
168
|
+
type: "info",
|
|
169
|
+
message: t("plugin_settings.bulk_action_updating_entries")
|
|
170
|
+
});
|
|
171
|
+
const { default: EntryExclusionService } = await Promise.resolve().then(() => require("./entry-exclusion-service-CGV6iOkB.js"));
|
|
172
|
+
const documentIds = documents.map((doc) => doc.documentId);
|
|
173
|
+
await EntryExclusionService.setMultipleEntriesExclusion(model, documentIds, false);
|
|
174
|
+
toggleNotification({
|
|
175
|
+
type: "success",
|
|
176
|
+
message: t("plugin_settings.bulk_action_success_message"),
|
|
177
|
+
timeout: 5e3
|
|
178
|
+
});
|
|
179
|
+
} catch (error) {
|
|
180
|
+
console.error("Failed to include entries to translation:", error);
|
|
181
|
+
toggleNotification({
|
|
182
|
+
type: "danger",
|
|
183
|
+
message: t("plugin_settings.bulk_action_failed_message")
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
IncludeToTranslationAction.type = "include-translation";
|
|
190
|
+
contentManagerPlugin.apis.addBulkAction([ExcludeFromTranslationAction, IncludeToTranslationAction]);
|
|
191
|
+
} else {
|
|
192
|
+
console.warn('Localazy Plugin: Content Manager "addBulkAction" API not available');
|
|
193
|
+
}
|
|
194
|
+
} catch (error) {
|
|
195
|
+
console.error("Localazy Plugin: Error adding side panel:", error);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const addMenuLink = (app) => {
|
|
200
|
+
app.addMenuLink({
|
|
201
|
+
to: `plugins/${PLUGIN_ID}/`,
|
|
202
|
+
icon: Localazy,
|
|
203
|
+
intlLabel: {
|
|
204
|
+
id: `${PLUGIN_ID}.name`,
|
|
205
|
+
defaultMessage: "Localazy"
|
|
206
|
+
},
|
|
207
|
+
Component: () => Promise.resolve().then(() => require("./LocalazyApp-DnaA768k.js"))
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
const addSettingsSection = (app) => {
|
|
211
|
+
app.addSettingsLink(
|
|
212
|
+
{
|
|
213
|
+
id: `${PLUGIN_ID}-settings`,
|
|
214
|
+
intlLabel: {
|
|
215
|
+
id: `${PLUGIN_ID}.localazy_settings`,
|
|
216
|
+
defaultMessage: "Localazy Settings"
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
[
|
|
220
|
+
// General
|
|
221
|
+
{
|
|
222
|
+
id: `${PLUGIN_ID}-settings-global`,
|
|
223
|
+
intlLabel: {
|
|
224
|
+
id: `${PLUGIN_ID}.localazy_settings`,
|
|
225
|
+
defaultMessage: "Localazy Settings"
|
|
226
|
+
},
|
|
227
|
+
to: `${PLUGIN_ID}/global-settings`,
|
|
228
|
+
Component: () => Promise.resolve().then(() => require("./LocalazyGlobalSettings-ewETL3oG.js")),
|
|
229
|
+
permissions: []
|
|
230
|
+
},
|
|
231
|
+
// Content Transfer Setup
|
|
232
|
+
{
|
|
233
|
+
id: `${PLUGIN_ID}-settings-content-transfer-setup`,
|
|
234
|
+
intlLabel: {
|
|
235
|
+
id: `${PLUGIN_ID}.content_transfer_setup`,
|
|
236
|
+
defaultMessage: "Content Transfer Setup"
|
|
237
|
+
},
|
|
238
|
+
to: `${PLUGIN_ID}/content-transfer-setup`,
|
|
239
|
+
Component: () => Promise.resolve().then(() => require("./LocalazyContentTransferSetup-CeOM6bYA.js")),
|
|
240
|
+
permissions: []
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
);
|
|
244
|
+
};
|
|
245
|
+
const addPlugin = (app) => {
|
|
246
|
+
app.registerPlugin({
|
|
247
|
+
id: PLUGIN_ID,
|
|
248
|
+
initializer: Initializer,
|
|
249
|
+
isReady: false,
|
|
250
|
+
name: PLUGIN_ID
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
exports.PLUGIN_ID = PLUGIN_ID;
|
|
254
|
+
exports.index = index;
|