@tachybase/plugin-i18n-editor 0.23.8 → 0.23.14
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/externalVersion.js +7 -7
- package/dist/node_modules/deepmerge/package.json +1 -1
- package/dist/server/actions/localization.js +12 -1
- package/dist/server/plugin.js +8 -0
- package/dist/server/resources.d.ts +5 -0
- package/dist/server/resources.js +12 -1
- package/package.json +11 -10
- package/.turbo/turbo-build.log +0 -14
package/dist/externalVersion.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.3.1",
|
|
3
|
-
"@tachybase/client": "0.23.
|
|
4
|
-
"@tachybase/schema": "0.23.
|
|
3
|
+
"@tachybase/client": "0.23.14",
|
|
4
|
+
"@tachybase/schema": "0.23.14",
|
|
5
5
|
"@ant-design/icons": "5.5.2",
|
|
6
6
|
"ahooks": "3.8.4",
|
|
7
7
|
"antd": "5.22.5",
|
|
8
|
-
"@tachybase/database": "0.23.
|
|
9
|
-
"@tachybase/module-ui-schema": "0.23.
|
|
10
|
-
"@tachybase/server": "0.23.
|
|
11
|
-
"@tachybase/cache": "0.23.
|
|
8
|
+
"@tachybase/database": "0.23.14",
|
|
9
|
+
"@tachybase/module-ui-schema": "0.23.14",
|
|
10
|
+
"@tachybase/server": "0.23.14",
|
|
11
|
+
"@tachybase/cache": "0.23.14",
|
|
12
12
|
"react-i18next": "15.2.0",
|
|
13
|
-
"@tachybase/actions": "0.23.
|
|
13
|
+
"@tachybase/actions": "0.23.14"
|
|
14
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"deepmerge","description":"A library for deep (recursive) merging of Javascript objects","keywords":["merge","deep","extend","copy","clone","recursive"],"version":"4.3.1","homepage":"https://github.com/TehShrike/deepmerge","repository":{"type":"git","url":"git://github.com/TehShrike/deepmerge.git"},"main":"dist/cjs.js","engines":{"node":">=0.10.0"},"scripts":{"build":"rollup -c","test":"npm run build && tape test/*.js && jsmd readme.md && npm run test:typescript","test:typescript":"tsc --noEmit test/typescript.ts && ts-node test/typescript.ts","size":"npm run build && uglifyjs --compress --mangle -- ./dist/umd.js | gzip -c | wc -c"},"devDependencies":{"@types/node":"^8.10.54","is-mergeable-object":"1.1.0","is-plain-object":"^5.0.0","jsmd":"^1.0.2","rollup":"^1.23.1","rollup-plugin-commonjs":"^10.1.0","rollup-plugin-node-resolve":"^5.2.0","tape":"^4.11.0","ts-node":"7.0.1","typescript":"=2.2.2","uglify-js":"^3.6.1"},"license":"MIT","_lastModified":"2024-12-
|
|
1
|
+
{"name":"deepmerge","description":"A library for deep (recursive) merging of Javascript objects","keywords":["merge","deep","extend","copy","clone","recursive"],"version":"4.3.1","homepage":"https://github.com/TehShrike/deepmerge","repository":{"type":"git","url":"git://github.com/TehShrike/deepmerge.git"},"main":"dist/cjs.js","engines":{"node":">=0.10.0"},"scripts":{"build":"rollup -c","test":"npm run build && tape test/*.js && jsmd readme.md && npm run test:typescript","test:typescript":"tsc --noEmit test/typescript.ts && ts-node test/typescript.ts","size":"npm run build && uglifyjs --compress --mangle -- ./dist/umd.js | gzip -c | wc -c"},"devDependencies":{"@types/node":"^8.10.54","is-mergeable-object":"1.1.0","is-plain-object":"^5.0.0","jsmd":"^1.0.2","rollup":"^1.23.1","rollup-plugin-commonjs":"^10.1.0","rollup-plugin-node-resolve":"^5.2.0","tape":"^4.11.0","ts-node":"7.0.1","typescript":"=2.2.2","uglify-js":"^3.6.1"},"license":"MIT","_lastModified":"2024-12-26T05:54:25.347Z"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
var localization_exports = {};
|
|
19
29
|
__export(localization_exports, {
|
|
@@ -26,9 +36,10 @@ __export(localization_exports, {
|
|
|
26
36
|
module.exports = __toCommonJS(localization_exports);
|
|
27
37
|
var import_database = require("@tachybase/database");
|
|
28
38
|
var import_constans = require("../constans");
|
|
39
|
+
var import_plugin = __toESM(require("../plugin"));
|
|
29
40
|
var import_utils = require("../utils");
|
|
30
41
|
const getResourcesInstance = async (ctx) => {
|
|
31
|
-
const plugin = ctx.app.getPlugin(
|
|
42
|
+
const plugin = ctx.app.getPlugin(import_plugin.default);
|
|
32
43
|
return plugin.resources;
|
|
33
44
|
};
|
|
34
45
|
const getResources = async (ctx) => {
|
package/dist/server/plugin.js
CHANGED
|
@@ -125,6 +125,14 @@ class LocalizationManagementPlugin extends import_server.Plugin {
|
|
|
125
125
|
await next();
|
|
126
126
|
const { resourceName, actionName } = ctx.action;
|
|
127
127
|
if (resourceName === "app" && actionName === "getLang") {
|
|
128
|
+
const pluginETag = await this.resources.getETag(ctx.get("X-Locale") || "en-US");
|
|
129
|
+
const responseETag = ctx.response.get("ETag") || "";
|
|
130
|
+
if (ctx.status === 304 && responseETag && responseETag.substring(37, 37 + 36) === pluginETag) {
|
|
131
|
+
ctx.status = 304;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
ctx.status = 200;
|
|
135
|
+
ctx.set("ETag", `${responseETag.substring(0, 36)}-${pluginETag}`);
|
|
128
136
|
const custom = await this.resources.getResources(ctx.get("X-Locale") || "en-US");
|
|
129
137
|
const appLang = ctx.body;
|
|
130
138
|
const resources = { ...appLang.resources };
|
|
@@ -4,8 +4,13 @@ export default class Resources {
|
|
|
4
4
|
cache: Cache;
|
|
5
5
|
db: Database;
|
|
6
6
|
constructor(db: Database, cache: Cache);
|
|
7
|
+
getETag(locale: string): Promise<`${string}-${string}-${string}-${string}-${string}`>;
|
|
7
8
|
getTexts(transaction?: Transaction): Promise<any>;
|
|
8
9
|
getTranslations(locale: string): Promise<any>;
|
|
10
|
+
getTranslationsCache(locale: string): Promise<{
|
|
11
|
+
result: any;
|
|
12
|
+
eTag: `${string}-${string}-${string}-${string}-${string}`;
|
|
13
|
+
}>;
|
|
9
14
|
getResources(locale: string): Promise<{}>;
|
|
10
15
|
filterExists(texts: {
|
|
11
16
|
text: string;
|
package/dist/server/resources.js
CHANGED
|
@@ -20,6 +20,7 @@ __export(resources_exports, {
|
|
|
20
20
|
default: () => Resources
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(resources_exports);
|
|
23
|
+
var import_crypto = require("crypto");
|
|
23
24
|
class Resources {
|
|
24
25
|
cache;
|
|
25
26
|
db;
|
|
@@ -27,6 +28,10 @@ class Resources {
|
|
|
27
28
|
this.cache = cache;
|
|
28
29
|
this.db = db;
|
|
29
30
|
}
|
|
31
|
+
async getETag(locale) {
|
|
32
|
+
const { eTag } = await this.getTranslationsCache(locale);
|
|
33
|
+
return eTag;
|
|
34
|
+
}
|
|
30
35
|
async getTexts(transaction) {
|
|
31
36
|
return await this.cache.wrap(`texts`, async () => {
|
|
32
37
|
return await this.db.getRepository("localizationTexts").find({
|
|
@@ -37,12 +42,18 @@ class Resources {
|
|
|
37
42
|
});
|
|
38
43
|
}
|
|
39
44
|
async getTranslations(locale) {
|
|
45
|
+
const response = await this.getTranslationsCache(locale);
|
|
46
|
+
return response.result;
|
|
47
|
+
}
|
|
48
|
+
async getTranslationsCache(locale) {
|
|
40
49
|
return await this.cache.wrap(`translations:${locale}`, async () => {
|
|
41
|
-
|
|
50
|
+
const result = await this.db.getRepository("localizationTranslations").find({
|
|
42
51
|
fields: ["textId", "translation"],
|
|
43
52
|
filter: { locale },
|
|
44
53
|
raw: true
|
|
45
54
|
});
|
|
55
|
+
this.cache.del(`translationsETag:${locale}`);
|
|
56
|
+
return { result, eTag: (0, import_crypto.randomUUID)() };
|
|
46
57
|
});
|
|
47
58
|
}
|
|
48
59
|
async getResources(locale) {
|
package/package.json
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/plugin-i18n-editor",
|
|
3
3
|
"displayName": "Localization",
|
|
4
|
-
"version": "0.23.
|
|
4
|
+
"version": "0.23.14",
|
|
5
5
|
"description": "Allows to manage localization resources of the application.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"System management"
|
|
8
8
|
],
|
|
9
9
|
"license": "Apache-2.0",
|
|
10
10
|
"main": "dist/server/index.js",
|
|
11
|
+
"dependencies": {},
|
|
11
12
|
"devDependencies": {
|
|
12
13
|
"@ant-design/icons": "^5.5.2",
|
|
13
14
|
"ahooks": "^3.8.4",
|
|
14
15
|
"antd": "5.22.5",
|
|
15
16
|
"deepmerge": "^4.3.1",
|
|
16
17
|
"react-i18next": "^15.2.0",
|
|
17
|
-
"@tachybase/schema": "0.23.
|
|
18
|
+
"@tachybase/schema": "0.23.14"
|
|
18
19
|
},
|
|
19
20
|
"peerDependencies": {
|
|
20
|
-
"@tachybase/actions": "0.23.
|
|
21
|
-
"@tachybase/
|
|
22
|
-
"@tachybase/
|
|
23
|
-
"@tachybase/
|
|
24
|
-
"@tachybase/
|
|
25
|
-
"@tachybase/
|
|
26
|
-
"@tachybase/module-ui-schema": "0.23.
|
|
27
|
-
"@tachybase/
|
|
21
|
+
"@tachybase/actions": "0.23.14",
|
|
22
|
+
"@tachybase/cache": "0.23.14",
|
|
23
|
+
"@tachybase/client": "0.23.14",
|
|
24
|
+
"@tachybase/database": "0.23.14",
|
|
25
|
+
"@tachybase/module-web": "0.23.14",
|
|
26
|
+
"@tachybase/test": "0.23.14",
|
|
27
|
+
"@tachybase/module-ui-schema": "0.23.14",
|
|
28
|
+
"@tachybase/server": "0.23.14"
|
|
28
29
|
},
|
|
29
30
|
"description.zh-CN": "支持管理应用程序的本地化资源。",
|
|
30
31
|
"displayName.zh-CN": "本地化",
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
> @tachybase/plugin-i18n-editor@0.23.2 build /Users/seal/Documents/projects/tachybase/packages/plugin-i18n-editor
|
|
4
|
-
> tachybase-build --no-dts @tachybase/plugin-i18n-editor
|
|
5
|
-
|
|
6
|
-
[33m[33mThe CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.[39m[39m
|
|
7
|
-
[4m[95m@tachybase/plugin-i18n-editor[39m[24m: [1mplugin-i18n-editor[22m build start
|
|
8
|
-
[4m[95m@tachybase/plugin-i18n-editor[39m[24m: build plugin client
|
|
9
|
-
[4m[95m@tachybase/plugin-i18n-editor[39m[24m: build plugin server source
|
|
10
|
-
[4m[95m@tachybase/plugin-i18n-editor[39m[24m: delete server files
|
|
11
|
-
[4m[95m@tachybase/plugin-i18n-editor[39m[24m: build plugin server dependencies
|
|
12
|
-
[4m[95m@tachybase/plugin-i18n-editor[39m[24m: These packages [33mdeepmerge[39m will be [3mbundled[23m to dist/node_modules. These packages [33m@tachybase/database, @tachybase/module-ui-schema, @tachybase/server, @tachybase/cache, @tachybase/actions[39m will be [3mexclude[23m.
|
|
13
|
-
[4m[95m@tachybase/plugin-i18n-editor[39m[24m: write external version
|
|
14
|
-
|