@rdyl/react-i18n-connect 0.0.6 → 0.0.7
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/CHANGELOG.md +1 -1
- package/dist/index.js +4 -0
- package/dist/utils.js +17 -0
- package/package.json +1 -1
- package/types/index.d.ts +1 -0
- package/types/utils.d.ts +4 -0
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -32,6 +32,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
exports.useI18n = void 0;
|
|
37
40
|
var react_1 = __importStar(require("react"));
|
|
@@ -92,4 +95,5 @@ var I18nConnect = function (_a) {
|
|
|
92
95
|
};
|
|
93
96
|
var useI18n = function () { return (0, react_1.useContext)(I18nCtx); };
|
|
94
97
|
exports.useI18n = useI18n;
|
|
98
|
+
__exportStar(require("./utils"), exports);
|
|
95
99
|
exports.default = I18nConnect;
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ParserI18nFn = ParserI18nFn;
|
|
4
|
+
exports.viteLoadI18nLocales = viteLoadI18nLocales;
|
|
4
5
|
function ParserI18nFn(data) {
|
|
5
6
|
return function (k, named) {
|
|
6
7
|
var text = data[k];
|
|
@@ -16,3 +17,19 @@ function ParserI18nFn(data) {
|
|
|
16
17
|
return text;
|
|
17
18
|
};
|
|
18
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* @description 使用vite时可用
|
|
22
|
+
*/
|
|
23
|
+
function viteLoadI18nLocales(path) {
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
var modules = import.meta.glob("".concat(path, "/**/*.json"), { eager: true });
|
|
26
|
+
var result = {};
|
|
27
|
+
Object.entries(modules).forEach(function (_a) {
|
|
28
|
+
var path = _a[0], module = _a[1];
|
|
29
|
+
// 将文件路径转换为嵌套结构
|
|
30
|
+
var parts = path.replace("".concat(path, "/"), "").split("/");
|
|
31
|
+
var name = parts.map(function (e) { return e.replace(".json", ""); }).join("-");
|
|
32
|
+
result[name] = module.default;
|
|
33
|
+
});
|
|
34
|
+
return result;
|
|
35
|
+
}
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
package/types/utils.d.ts
CHANGED