@bleedingdev/modern-js-plugin-i18n 3.2.0-ultramodern.99 → 3.4.0-ultramodern.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.
- package/README.md +221 -11
- package/dist/cjs/cli/index.js +17 -64
- package/dist/cjs/cli/locales.js +132 -0
- package/dist/cjs/runtime/I18nLink.js +17 -20
- package/dist/cjs/runtime/Link.js +264 -0
- package/dist/cjs/runtime/canonicalRoutes.js +18 -0
- package/dist/cjs/runtime/context.js +9 -5
- package/dist/cjs/runtime/hooks.js +9 -5
- package/dist/cjs/runtime/i18n/backend/config.js +9 -5
- package/dist/cjs/runtime/i18n/backend/defaults.js +20 -11
- package/dist/cjs/runtime/i18n/backend/defaults.node.js +79 -10
- package/dist/cjs/runtime/i18n/backend/index.js +9 -5
- package/dist/cjs/runtime/i18n/backend/middleware.common.js +9 -5
- package/dist/cjs/runtime/i18n/backend/middleware.js +9 -5
- package/dist/cjs/runtime/i18n/backend/middleware.node.js +9 -5
- package/dist/cjs/runtime/i18n/backend/sdk-backend.js +9 -5
- package/dist/cjs/runtime/i18n/backend/sdk-event.js +16 -11
- package/dist/cjs/runtime/i18n/detection/config.js +9 -5
- package/dist/cjs/runtime/i18n/detection/index.js +9 -5
- package/dist/cjs/runtime/i18n/detection/middleware.js +9 -5
- package/dist/cjs/runtime/i18n/detection/middleware.node.js +9 -5
- package/dist/cjs/runtime/i18n/index.js +9 -5
- package/dist/cjs/runtime/i18n/instance.js +17 -13
- package/dist/cjs/runtime/i18n/react-i18next.js +12 -8
- package/dist/cjs/runtime/i18n/utils.js +9 -5
- package/dist/cjs/runtime/index.js +32 -5
- package/dist/cjs/runtime/localizedPaths.js +102 -0
- package/dist/cjs/runtime/routerAdapter.js +11 -7
- package/dist/cjs/runtime/utils.js +31 -17
- package/dist/cjs/server/index.js +10 -14
- package/dist/cjs/shared/deepMerge.js +12 -8
- package/dist/cjs/shared/detection.js +9 -5
- package/dist/cjs/shared/localisedUrls.js +148 -34
- package/dist/cjs/shared/utils.js +15 -11
- package/dist/esm/cli/index.mjs +8 -48
- package/dist/esm/cli/locales.mjs +80 -0
- package/dist/esm/runtime/I18nLink.mjs +7 -14
- package/dist/esm/runtime/Link.mjs +221 -0
- package/dist/esm/runtime/canonicalRoutes.mjs +0 -0
- package/dist/esm/runtime/i18n/backend/defaults.mjs +6 -2
- package/dist/esm/runtime/i18n/backend/defaults.node.mjs +56 -5
- package/dist/esm/runtime/index.mjs +4 -2
- package/dist/esm/runtime/localizedPaths.mjs +55 -0
- package/dist/esm/runtime/routerAdapter.mjs +3 -3
- package/dist/esm/runtime/utils.mjs +19 -12
- package/dist/esm/server/index.mjs +2 -10
- package/dist/esm/shared/localisedUrls.mjs +115 -23
- package/dist/esm-node/cli/index.mjs +8 -48
- package/dist/esm-node/cli/locales.mjs +81 -0
- package/dist/esm-node/runtime/I18nLink.mjs +7 -14
- package/dist/esm-node/runtime/Link.mjs +222 -0
- package/dist/esm-node/runtime/canonicalRoutes.mjs +1 -0
- package/dist/esm-node/runtime/i18n/backend/defaults.mjs +6 -2
- package/dist/esm-node/runtime/i18n/backend/defaults.node.mjs +56 -5
- package/dist/esm-node/runtime/index.mjs +4 -2
- package/dist/esm-node/runtime/localizedPaths.mjs +56 -0
- package/dist/esm-node/runtime/routerAdapter.mjs +3 -3
- package/dist/esm-node/runtime/utils.mjs +19 -12
- package/dist/esm-node/server/index.mjs +2 -10
- package/dist/esm-node/shared/localisedUrls.mjs +115 -23
- package/dist/types/cli/index.d.ts +1 -0
- package/dist/types/cli/locales.d.ts +17 -0
- package/dist/types/runtime/I18nLink.d.ts +4 -13
- package/dist/types/runtime/Link.d.ts +66 -0
- package/dist/types/runtime/canonicalRoutes.d.ts +60 -0
- package/dist/types/runtime/i18n/backend/defaults.d.ts +10 -7
- package/dist/types/runtime/i18n/backend/defaults.node.d.ts +13 -4
- package/dist/types/runtime/index.d.ts +5 -1
- package/dist/types/runtime/localizedPaths.d.ts +39 -0
- package/dist/types/runtime/types.d.ts +1 -1
- package/dist/types/runtime/utils.d.ts +13 -4
- package/dist/types/shared/localisedUrls.d.ts +23 -0
- package/dist/types/shared/type.d.ts +27 -5
- package/package.json +28 -25
- package/rstest.config.mts +7 -2
- package/src/cli/index.ts +25 -98
- package/src/cli/locales.ts +186 -0
- package/src/runtime/I18nLink.tsx +13 -44
- package/src/runtime/Link.tsx +430 -0
- package/src/runtime/canonicalRoutes.ts +93 -0
- package/src/runtime/i18n/backend/defaults.node.ts +112 -7
- package/src/runtime/i18n/backend/defaults.ts +20 -18
- package/src/runtime/index.tsx +24 -2
- package/src/runtime/localizedPaths.ts +107 -0
- package/src/runtime/routerAdapter.tsx +4 -5
- package/src/runtime/types.ts +1 -1
- package/src/runtime/utils.ts +33 -26
- package/src/server/index.ts +7 -17
- package/src/shared/localisedUrls.ts +256 -26
- package/src/shared/type.ts +27 -5
- package/tests/backendDefaults.test.ts +51 -0
- package/tests/i18nUtils.test.ts +10 -3
- package/tests/link.test.tsx +525 -0
- package/tests/linkTypes.test.ts +28 -0
- package/tests/localisedUrls.test.ts +224 -0
- package/tests/routerAdapter.test.tsx +86 -12
- package/tests/type-fixture/linkTypes.fixture.tsx +51 -0
- package/tests/type-fixture/tsconfig.json +15 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
Link: ()=>Link,
|
|
32
|
+
default: ()=>runtime_Link,
|
|
33
|
+
interpolateRouteParams: ()=>interpolateRouteParams
|
|
34
|
+
});
|
|
35
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
36
|
+
const external_react_namespaceObject = require("react");
|
|
37
|
+
const external_context_js_namespaceObject = require("./context.js");
|
|
38
|
+
const external_localizedPaths_js_namespaceObject = require("./localizedPaths.js");
|
|
39
|
+
const external_routerAdapter_js_namespaceObject = require("./routerAdapter.js");
|
|
40
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
41
|
+
const EXTERNAL_TARGET_RE = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
42
|
+
const warnedTargets = new Set();
|
|
43
|
+
const warnOnce = (key, message)=>{
|
|
44
|
+
if ('development' !== process.env.NODE_ENV || warnedTargets.has(key)) return;
|
|
45
|
+
warnedTargets.add(key);
|
|
46
|
+
console.warn(message);
|
|
47
|
+
};
|
|
48
|
+
const interpolateRouteParams = (pathname, params)=>{
|
|
49
|
+
if (!/[$:*{]/.test(pathname)) return pathname;
|
|
50
|
+
const resolveParam = (name)=>{
|
|
51
|
+
const value = params?.[name];
|
|
52
|
+
return void 0 === value ? void 0 : String(value);
|
|
53
|
+
};
|
|
54
|
+
const segments = pathname.split('/').map((segment)=>{
|
|
55
|
+
if (!segment) return segment;
|
|
56
|
+
if (segment.startsWith('{-$') && segment.endsWith('}')) {
|
|
57
|
+
const value = resolveParam(segment.slice(3, -1));
|
|
58
|
+
return void 0 === value ? null : encodeURIComponent(value);
|
|
59
|
+
}
|
|
60
|
+
if ('$' === segment || '*' === segment) {
|
|
61
|
+
const value = resolveParam('_splat') ?? resolveParam('*');
|
|
62
|
+
return void 0 === value ? null : value.split('/').map(encodeURIComponent).join('/');
|
|
63
|
+
}
|
|
64
|
+
if (segment.startsWith('$')) {
|
|
65
|
+
const value = resolveParam(segment.slice(1));
|
|
66
|
+
if (void 0 === value) {
|
|
67
|
+
warnOnce(`missing-param:${pathname}:${segment}`, `[plugin-i18n] <Link to="${pathname}"> is missing required param "${segment.slice(1)}".`);
|
|
68
|
+
return segment;
|
|
69
|
+
}
|
|
70
|
+
return encodeURIComponent(value);
|
|
71
|
+
}
|
|
72
|
+
if (segment.startsWith(':')) {
|
|
73
|
+
const optional = segment.endsWith('?');
|
|
74
|
+
const name = segment.slice(1, optional ? -1 : void 0);
|
|
75
|
+
const value = resolveParam(name);
|
|
76
|
+
if (void 0 === value) {
|
|
77
|
+
if (optional) return null;
|
|
78
|
+
warnOnce(`missing-param:${pathname}:${segment}`, `[plugin-i18n] <Link to="${pathname}"> is missing required param "${name}".`);
|
|
79
|
+
return segment;
|
|
80
|
+
}
|
|
81
|
+
return encodeURIComponent(value);
|
|
82
|
+
}
|
|
83
|
+
return segment;
|
|
84
|
+
}).filter((segment)=>null !== segment);
|
|
85
|
+
return segments.join('/') || '/';
|
|
86
|
+
};
|
|
87
|
+
const normalizeSearch = (search, searchFromTo)=>{
|
|
88
|
+
if (search && 'object' == typeof search) {
|
|
89
|
+
const entries = Object.entries(search).filter(([, value])=>null != value);
|
|
90
|
+
const searchObject = Object.fromEntries(entries.map(([key, value])=>[
|
|
91
|
+
key,
|
|
92
|
+
String(value)
|
|
93
|
+
]));
|
|
94
|
+
const params = new URLSearchParams(searchObject);
|
|
95
|
+
const serialized = params.toString();
|
|
96
|
+
return {
|
|
97
|
+
searchString: serialized ? `?${serialized}` : '',
|
|
98
|
+
searchObject
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const raw = 'string' == typeof search && search ? search : searchFromTo;
|
|
102
|
+
if (!raw) return {
|
|
103
|
+
searchString: '',
|
|
104
|
+
searchObject: void 0
|
|
105
|
+
};
|
|
106
|
+
const searchString = raw.startsWith('?') ? raw : `?${raw}`;
|
|
107
|
+
const searchObject = {};
|
|
108
|
+
new URLSearchParams(searchString).forEach((value, key)=>{
|
|
109
|
+
searchObject[key] = value;
|
|
110
|
+
});
|
|
111
|
+
return {
|
|
112
|
+
searchString,
|
|
113
|
+
searchObject
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
const splitActiveProps = (active, activeProps)=>{
|
|
117
|
+
if (!active || !activeProps) return {};
|
|
118
|
+
return activeProps;
|
|
119
|
+
};
|
|
120
|
+
const mergeClassNames = (...values)=>{
|
|
121
|
+
const classNames = values.filter((value)=>'string' == typeof value && value.length > 0);
|
|
122
|
+
return classNames.length > 0 ? classNames.join(' ') : void 0;
|
|
123
|
+
};
|
|
124
|
+
const Link = (props)=>{
|
|
125
|
+
const { to, params, children, hash: hashProp, search: searchProp, hashScrollIntoView, activeOptions, activeProps, prefetch, preload, ...rest } = props;
|
|
126
|
+
const adapter = (0, external_routerAdapter_js_namespaceObject.useI18nRouterAdapter)();
|
|
127
|
+
const { language, supportedLanguages, localisedUrls } = (0, external_context_js_namespaceObject.useModernI18n)();
|
|
128
|
+
const config = {
|
|
129
|
+
languages: supportedLanguages,
|
|
130
|
+
localisedUrls
|
|
131
|
+
};
|
|
132
|
+
const isExternal = EXTERNAL_TARGET_RE.test(to);
|
|
133
|
+
const isBareHash = to.startsWith('#');
|
|
134
|
+
const target = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
135
|
+
if (isExternal || isBareHash) return null;
|
|
136
|
+
const { pathname, search: searchFromTo, hash: hashFromTo } = (0, external_utils_js_namespaceObject.splitUrlTarget)(to);
|
|
137
|
+
const interpolated = interpolateRouteParams(pathname || '/', params);
|
|
138
|
+
const firstSegment = interpolated.split('/').filter(Boolean)[0];
|
|
139
|
+
if (firstSegment && supportedLanguages.includes(firstSegment)) warnOnce(`lang-prefix:${to}`, `[plugin-i18n] <Link to="${to}"> starts with a language prefix. Write language-agnostic canonical paths; the Link localizes them automatically.`);
|
|
140
|
+
const localizedPathname = (0, external_utils_js_namespaceObject.buildLocalizedUrl)(interpolated, language, supportedLanguages, localisedUrls);
|
|
141
|
+
const hash = hashProp ?? (hashFromTo ? hashFromTo.slice(1) : '');
|
|
142
|
+
const { searchString, searchObject } = normalizeSearch(searchProp, searchFromTo);
|
|
143
|
+
return {
|
|
144
|
+
canonicalPathname: interpolated,
|
|
145
|
+
localizedPathname,
|
|
146
|
+
hash,
|
|
147
|
+
searchString,
|
|
148
|
+
searchObject,
|
|
149
|
+
href: `${localizedPathname}${searchString}${hash ? `#${hash}` : ''}`
|
|
150
|
+
};
|
|
151
|
+
}, [
|
|
152
|
+
to,
|
|
153
|
+
params,
|
|
154
|
+
hashProp,
|
|
155
|
+
searchProp,
|
|
156
|
+
isExternal,
|
|
157
|
+
isBareHash,
|
|
158
|
+
language,
|
|
159
|
+
supportedLanguages,
|
|
160
|
+
localisedUrls
|
|
161
|
+
]);
|
|
162
|
+
const isActive = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
163
|
+
if (!target || !adapter.location) return false;
|
|
164
|
+
const current = (0, external_localizedPaths_js_namespaceObject.canonicalPath)(adapter.location.pathname, config);
|
|
165
|
+
const targetCanonical = (0, external_localizedPaths_js_namespaceObject.canonicalPath)(target.canonicalPathname, config);
|
|
166
|
+
const exact = activeOptions?.exact ?? '/' === targetCanonical;
|
|
167
|
+
if (current === targetCanonical) return true;
|
|
168
|
+
if (exact) return false;
|
|
169
|
+
return current.startsWith('/' === targetCanonical ? '/' : `${targetCanonical}/`);
|
|
170
|
+
}, [
|
|
171
|
+
target,
|
|
172
|
+
adapter.location,
|
|
173
|
+
activeOptions?.exact,
|
|
174
|
+
supportedLanguages,
|
|
175
|
+
localisedUrls
|
|
176
|
+
]);
|
|
177
|
+
const resolvedActiveProps = splitActiveProps(isActive, activeProps);
|
|
178
|
+
const activeAttributes = isActive ? {
|
|
179
|
+
'data-status': 'active',
|
|
180
|
+
'aria-current': rest['aria-current'] ?? resolvedActiveProps['aria-current'] ?? 'page'
|
|
181
|
+
} : {};
|
|
182
|
+
if (!target) {
|
|
183
|
+
const { replace: _replace, ...anchorProps } = rest;
|
|
184
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("a", {
|
|
185
|
+
href: to,
|
|
186
|
+
...anchorProps,
|
|
187
|
+
children: children
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
const { Link: RouterLink, hasRouter, framework } = adapter;
|
|
191
|
+
if (!hasRouter || !RouterLink) {
|
|
192
|
+
const { replace: _replace, ...anchorProps } = rest;
|
|
193
|
+
const { className: activeClassName, style: activeStyle, ...activeRest } = resolvedActiveProps;
|
|
194
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("a", {
|
|
195
|
+
href: target.href,
|
|
196
|
+
...anchorProps,
|
|
197
|
+
...activeRest,
|
|
198
|
+
...activeAttributes,
|
|
199
|
+
className: mergeClassNames(rest.className, activeClassName),
|
|
200
|
+
style: {
|
|
201
|
+
...rest.style,
|
|
202
|
+
...activeStyle
|
|
203
|
+
},
|
|
204
|
+
children: children
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
const { className: activeClassName, style: activeStyle, ...activeRest } = resolvedActiveProps;
|
|
208
|
+
const mergedClassName = mergeClassNames(rest.className, activeClassName);
|
|
209
|
+
const mergedStyle = {
|
|
210
|
+
...rest.style,
|
|
211
|
+
...activeStyle
|
|
212
|
+
};
|
|
213
|
+
if ('tanstack' === framework) {
|
|
214
|
+
const tanstackPreload = void 0 !== preload ? preload : void 0 === prefetch ? void 0 : 'none' === prefetch ? false : prefetch;
|
|
215
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RouterLink, {
|
|
216
|
+
to: target.localizedPathname,
|
|
217
|
+
...target.searchObject ? {
|
|
218
|
+
search: target.searchObject
|
|
219
|
+
} : {},
|
|
220
|
+
...target.hash ? {
|
|
221
|
+
hash: target.hash
|
|
222
|
+
} : {},
|
|
223
|
+
...void 0 === hashScrollIntoView ? {} : {
|
|
224
|
+
hashScrollIntoView
|
|
225
|
+
},
|
|
226
|
+
...void 0 === tanstackPreload ? {} : {
|
|
227
|
+
preload: tanstackPreload
|
|
228
|
+
},
|
|
229
|
+
...rest,
|
|
230
|
+
...activeRest,
|
|
231
|
+
...activeAttributes,
|
|
232
|
+
className: mergedClassName,
|
|
233
|
+
style: mergedStyle,
|
|
234
|
+
children: children
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RouterLink, {
|
|
238
|
+
to: target.href,
|
|
239
|
+
...void 0 === prefetch ? {} : {
|
|
240
|
+
prefetch
|
|
241
|
+
},
|
|
242
|
+
...void 0 === preload ? {} : {
|
|
243
|
+
preload
|
|
244
|
+
},
|
|
245
|
+
...rest,
|
|
246
|
+
...activeRest,
|
|
247
|
+
...activeAttributes,
|
|
248
|
+
className: mergedClassName,
|
|
249
|
+
style: mergedStyle,
|
|
250
|
+
children: children
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
const runtime_Link = Link;
|
|
254
|
+
exports.Link = __webpack_exports__.Link;
|
|
255
|
+
exports["default"] = __webpack_exports__["default"];
|
|
256
|
+
exports.interpolateRouteParams = __webpack_exports__.interpolateRouteParams;
|
|
257
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
258
|
+
"Link",
|
|
259
|
+
"default",
|
|
260
|
+
"interpolateRouteParams"
|
|
261
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
262
|
+
Object.defineProperty(exports, '__esModule', {
|
|
263
|
+
value: true
|
|
264
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -23,17 +27,11 @@ var __webpack_require__ = {};
|
|
|
23
27
|
})();
|
|
24
28
|
var __webpack_exports__ = {};
|
|
25
29
|
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
DEFAULT_I18NEXT_BACKEND_OPTIONS: ()=>DEFAULT_I18NEXT_BACKEND_OPTIONS,
|
|
28
|
-
convertBackendOptions: ()=>convertBackendOptions
|
|
29
|
-
});
|
|
30
30
|
const DEFAULT_I18NEXT_BACKEND_OPTIONS = {
|
|
31
31
|
loadPath: '/locales/{{lng}}/{{ns}}.json',
|
|
32
32
|
addPath: '/locales/{{lng}}/{{ns}}.json'
|
|
33
33
|
};
|
|
34
34
|
function convertPath(path) {
|
|
35
|
-
if (!path) return path;
|
|
36
|
-
if (path.startsWith('/')) return "u" < typeof window ? path : `${window.__assetPrefix__ || ''}${path}`;
|
|
37
35
|
return path;
|
|
38
36
|
}
|
|
39
37
|
function convertBackendOptions(options) {
|
|
@@ -41,10 +39,21 @@ function convertBackendOptions(options) {
|
|
|
41
39
|
const converted = {
|
|
42
40
|
...options
|
|
43
41
|
};
|
|
42
|
+
delete converted.serverLoadPath;
|
|
43
|
+
delete converted.serverAddPath;
|
|
44
|
+
delete converted.serverLoadPaths;
|
|
45
|
+
delete converted.serverAddPaths;
|
|
46
|
+
delete converted._detectedLoadPath;
|
|
47
|
+
delete converted._detectedAddPath;
|
|
44
48
|
if (converted.loadPath) converted.loadPath = convertPath(converted.loadPath);
|
|
45
49
|
if (converted.addPath) converted.addPath = convertPath(converted.addPath);
|
|
46
50
|
return converted;
|
|
47
51
|
}
|
|
52
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
53
|
+
convertBackendOptions: ()=>convertBackendOptions
|
|
54
|
+
}, {
|
|
55
|
+
DEFAULT_I18NEXT_BACKEND_OPTIONS: DEFAULT_I18NEXT_BACKEND_OPTIONS
|
|
56
|
+
});
|
|
48
57
|
exports.DEFAULT_I18NEXT_BACKEND_OPTIONS = __webpack_exports__.DEFAULT_I18NEXT_BACKEND_OPTIONS;
|
|
49
58
|
exports.convertBackendOptions = __webpack_exports__.convertBackendOptions;
|
|
50
59
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
8
|
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
9
22
|
};
|
|
10
23
|
})();
|
|
11
24
|
(()=>{
|
|
@@ -25,31 +38,87 @@ var __webpack_exports__ = {};
|
|
|
25
38
|
__webpack_require__.r(__webpack_exports__);
|
|
26
39
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
40
|
DEFAULT_I18NEXT_BACKEND_OPTIONS: ()=>DEFAULT_I18NEXT_BACKEND_OPTIONS,
|
|
28
|
-
convertBackendOptions: ()=>convertBackendOptions
|
|
41
|
+
convertBackendOptions: ()=>convertBackendOptions,
|
|
42
|
+
resolveDefaultLocalesDir: ()=>resolveDefaultLocalesDir
|
|
29
43
|
});
|
|
44
|
+
const external_fs_namespaceObject = require("fs");
|
|
45
|
+
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
46
|
+
const external_path_namespaceObject = require("path");
|
|
47
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
48
|
+
const CONVENTIONAL_LOCALES_DIRS = [
|
|
49
|
+
'./locales',
|
|
50
|
+
'./config/public/locales'
|
|
51
|
+
];
|
|
52
|
+
const isDirectory = (dirPath)=>{
|
|
53
|
+
try {
|
|
54
|
+
return external_fs_default().statSync(dirPath).isDirectory();
|
|
55
|
+
} catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const resolveDefaultLocalesDir = (cwd = process.cwd())=>{
|
|
60
|
+
for (const dir of CONVENTIONAL_LOCALES_DIRS)if (isDirectory(external_path_default().resolve(cwd, dir))) return dir;
|
|
61
|
+
return CONVENTIONAL_LOCALES_DIRS[0];
|
|
62
|
+
};
|
|
30
63
|
const DEFAULT_I18NEXT_BACKEND_OPTIONS = {
|
|
31
|
-
loadPath
|
|
32
|
-
|
|
64
|
+
get loadPath () {
|
|
65
|
+
return `${resolveDefaultLocalesDir()}/{{lng}}/{{ns}}.json`;
|
|
66
|
+
},
|
|
67
|
+
get addPath () {
|
|
68
|
+
return `${resolveDefaultLocalesDir()}/{{lng}}/{{ns}}.json`;
|
|
69
|
+
}
|
|
33
70
|
};
|
|
34
71
|
function convertPath(path) {
|
|
35
72
|
if (!path) return path;
|
|
36
73
|
if (path.startsWith('/')) return `.${path}`;
|
|
37
74
|
return path;
|
|
38
75
|
}
|
|
76
|
+
function shouldUseServerPath(currentPath, detectedPath) {
|
|
77
|
+
return !detectedPath || currentPath === detectedPath;
|
|
78
|
+
}
|
|
79
|
+
function getResourceBasePath(resourcePath) {
|
|
80
|
+
const markerIndex = resourcePath.indexOf('{{lng}}');
|
|
81
|
+
if (markerIndex < 0) return resourcePath;
|
|
82
|
+
return resourcePath.slice(0, markerIndex).replace(/[\\/]+$/, '');
|
|
83
|
+
}
|
|
84
|
+
function pathExists(resourcePath) {
|
|
85
|
+
try {
|
|
86
|
+
return external_fs_default().existsSync(getResourceBasePath(resourcePath));
|
|
87
|
+
} catch {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function getServerPath(pathCandidates, fallbackPath) {
|
|
92
|
+
const candidates = Array.from(new Set([
|
|
93
|
+
...pathCandidates || [],
|
|
94
|
+
fallbackPath
|
|
95
|
+
].filter(Boolean)));
|
|
96
|
+
return candidates.find(pathExists) || candidates[0];
|
|
97
|
+
}
|
|
39
98
|
function convertBackendOptions(options) {
|
|
40
99
|
if (!options) return options;
|
|
41
100
|
const converted = {
|
|
42
101
|
...options
|
|
43
102
|
};
|
|
44
|
-
if (converted.loadPath) converted.loadPath =
|
|
45
|
-
if (converted.
|
|
103
|
+
if ((converted.serverLoadPath || converted.serverLoadPaths) && shouldUseServerPath(converted.loadPath, converted._detectedLoadPath)) converted.loadPath = getServerPath(converted.serverLoadPaths, converted.serverLoadPath);
|
|
104
|
+
else if (converted.loadPath) converted.loadPath = convertPath(converted.loadPath);
|
|
105
|
+
if ((converted.serverAddPath || converted.serverAddPaths) && shouldUseServerPath(converted.addPath, converted._detectedAddPath)) converted.addPath = getServerPath(converted.serverAddPaths, converted.serverAddPath);
|
|
106
|
+
else if (converted.addPath) converted.addPath = convertPath(converted.addPath);
|
|
107
|
+
delete converted.serverLoadPath;
|
|
108
|
+
delete converted.serverAddPath;
|
|
109
|
+
delete converted.serverLoadPaths;
|
|
110
|
+
delete converted.serverAddPaths;
|
|
111
|
+
delete converted._detectedLoadPath;
|
|
112
|
+
delete converted._detectedAddPath;
|
|
46
113
|
return converted;
|
|
47
114
|
}
|
|
48
115
|
exports.DEFAULT_I18NEXT_BACKEND_OPTIONS = __webpack_exports__.DEFAULT_I18NEXT_BACKEND_OPTIONS;
|
|
49
116
|
exports.convertBackendOptions = __webpack_exports__.convertBackendOptions;
|
|
117
|
+
exports.resolveDefaultLocalesDir = __webpack_exports__.resolveDefaultLocalesDir;
|
|
50
118
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
51
119
|
"DEFAULT_I18NEXT_BACKEND_OPTIONS",
|
|
52
|
-
"convertBackendOptions"
|
|
120
|
+
"convertBackendOptions",
|
|
121
|
+
"resolveDefaultLocalesDir"
|
|
53
122
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
54
123
|
Object.defineProperty(exports, '__esModule', {
|
|
55
124
|
value: true
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
|
|
|
10
10
|
};
|
|
11
11
|
})();
|
|
12
12
|
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
18
22
|
};
|
|
19
23
|
})();
|
|
20
24
|
(()=>{
|
|
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
|
|
|
10
10
|
};
|
|
11
11
|
})();
|
|
12
12
|
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
18
22
|
};
|
|
19
23
|
})();
|
|
20
24
|
(()=>{
|
|
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
|
|
|
10
10
|
};
|
|
11
11
|
})();
|
|
12
12
|
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
18
22
|
};
|
|
19
23
|
})();
|
|
20
24
|
(()=>{
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|