@tachybase/plugin-i18n-editor 0.23.8

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.
Files changed (50) hide show
  1. package/.turbo/turbo-build.log +14 -0
  2. package/README.md +35 -0
  3. package/client.d.ts +3 -0
  4. package/client.js +65 -0
  5. package/dist/client/Localization.d.ts +2 -0
  6. package/dist/client/index.d.ts +5 -0
  7. package/dist/client/index.js +1 -0
  8. package/dist/client/locale/index.d.ts +2 -0
  9. package/dist/client/schemas/localization.d.ts +2 -0
  10. package/dist/externalVersion.js +14 -0
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.js +39 -0
  13. package/dist/locale/en-US.json +24 -0
  14. package/dist/locale/ko_KR.json +23 -0
  15. package/dist/locale/zh-CN.json +24 -0
  16. package/dist/node_modules/deepmerge/.editorconfig +7 -0
  17. package/dist/node_modules/deepmerge/.eslintcache +1 -0
  18. package/dist/node_modules/deepmerge/dist/cjs.js +1 -0
  19. package/dist/node_modules/deepmerge/dist/umd.js +139 -0
  20. package/dist/node_modules/deepmerge/index.d.ts +20 -0
  21. package/dist/node_modules/deepmerge/index.js +106 -0
  22. package/dist/node_modules/deepmerge/license.txt +21 -0
  23. package/dist/node_modules/deepmerge/package.json +1 -0
  24. package/dist/node_modules/deepmerge/rollup.config.js +22 -0
  25. package/dist/server/actions/localization.d.ts +11 -0
  26. package/dist/server/actions/localization.js +225 -0
  27. package/dist/server/actions/localizationTexts.d.ts +5 -0
  28. package/dist/server/actions/localizationTexts.js +130 -0
  29. package/dist/server/collections/localization-texts.d.ts +2 -0
  30. package/dist/server/collections/localization-texts.js +86 -0
  31. package/dist/server/collections/localization-translations.d.ts +2 -0
  32. package/dist/server/collections/localization-translations.js +84 -0
  33. package/dist/server/constans.d.ts +8 -0
  34. package/dist/server/constans.js +48 -0
  35. package/dist/server/index.d.ts +1 -0
  36. package/dist/server/index.js +33 -0
  37. package/dist/server/migrations/20230706200900-roles-add-translation.d.ts +6 -0
  38. package/dist/server/migrations/20230706200900-roles-add-translation.js +50 -0
  39. package/dist/server/migrations/20231206161851-fix-module.d.ts +6 -0
  40. package/dist/server/migrations/20231206161851-fix-module.js +91 -0
  41. package/dist/server/plugin.d.ts +15 -0
  42. package/dist/server/plugin.js +162 -0
  43. package/dist/server/resources.d.ts +19 -0
  44. package/dist/server/resources.js +86 -0
  45. package/dist/server/utils.d.ts +3 -0
  46. package/dist/server/utils.js +79 -0
  47. package/dist/swagger/index.json +156 -0
  48. package/package.json +34 -0
  49. package/server.d.ts +3 -0
  50. package/server.js +65 -0
@@ -0,0 +1,6 @@
1
+ import { Migration } from '@tachybase/server';
2
+ export default class FixModuleMigration extends Migration {
3
+ appVersion: string;
4
+ up(): Promise<void>;
5
+ down(): Promise<void>;
6
+ }
@@ -0,0 +1,91 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var fix_module_exports = {};
19
+ __export(fix_module_exports, {
20
+ default: () => FixModuleMigration
21
+ });
22
+ module.exports = __toCommonJS(fix_module_exports);
23
+ var import_database = require("@tachybase/database");
24
+ var import_server = require("@tachybase/server");
25
+ var import_localization = require("../actions/localization");
26
+ var import_constans = require("../constans");
27
+ class FixModuleMigration extends import_server.Migration {
28
+ appVersion = "<0.17.0-alpha.3";
29
+ async up() {
30
+ const result = await this.app.version.satisfies("<=0.17.0-alpha.4");
31
+ if (!result) {
32
+ return;
33
+ }
34
+ const resources = await this.app.localeManager.getCacheResources("zh-CN");
35
+ const menus = await (0, import_localization.getTextsFromMenu)(this.context.db, true);
36
+ const collections = await (0, import_localization.getTextsFromDB)(this.context.db);
37
+ const db = this.context.db;
38
+ await db.getCollection("localizationTexts").sync();
39
+ await db.sequelize.transaction(async (t) => {
40
+ const menuTexts = Object.keys(menus);
41
+ await db.getModel("localizationTexts").update(
42
+ {
43
+ module: `resources.${import_constans.NAMESPACE_MENUS}`
44
+ },
45
+ {
46
+ where: {
47
+ text: {
48
+ [import_database.Op.in]: menuTexts
49
+ }
50
+ },
51
+ transaction: t
52
+ }
53
+ );
54
+ const collectionTexts = Object.keys(collections);
55
+ await db.getModel("localizationTexts").update(
56
+ {
57
+ module: `resources.${import_constans.NAMESPACE_COLLECTIONS}`
58
+ },
59
+ {
60
+ where: {
61
+ text: {
62
+ [import_database.Op.in]: collectionTexts
63
+ }
64
+ },
65
+ transaction: t
66
+ }
67
+ );
68
+ for (const [module2, resource] of Object.entries(resources)) {
69
+ if (module2 === "client") {
70
+ continue;
71
+ }
72
+ const texts = Object.keys(resource);
73
+ await db.getModel("localizationTexts").update(
74
+ {
75
+ module: `resources.${module2}`
76
+ },
77
+ {
78
+ where: {
79
+ text: {
80
+ [import_database.Op.in]: texts
81
+ }
82
+ },
83
+ transaction: t
84
+ }
85
+ );
86
+ }
87
+ });
88
+ }
89
+ async down() {
90
+ }
91
+ }
@@ -0,0 +1,15 @@
1
+ import { ModuleUiSchema } from '@tachybase/module-ui-schema';
2
+ import { InstallOptions, Plugin } from '@tachybase/server';
3
+ import Resources from './resources';
4
+ export declare class LocalizationManagementPlugin extends Plugin {
5
+ resources: Resources;
6
+ registerUISchemahook(plugin?: ModuleUiSchema): void;
7
+ afterAdd(): void;
8
+ beforeLoad(): void;
9
+ load(): Promise<void>;
10
+ install(options?: InstallOptions): Promise<void>;
11
+ afterEnable(): Promise<void>;
12
+ afterDisable(): Promise<void>;
13
+ remove(): Promise<void>;
14
+ }
15
+ export default LocalizationManagementPlugin;
@@ -0,0 +1,162 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
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
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var plugin_exports = {};
29
+ __export(plugin_exports, {
30
+ LocalizationManagementPlugin: () => LocalizationManagementPlugin,
31
+ default: () => plugin_default
32
+ });
33
+ module.exports = __toCommonJS(plugin_exports);
34
+ var import_server = require("@tachybase/server");
35
+ var import_deepmerge = __toESM(require("deepmerge"));
36
+ var import_localization = __toESM(require("./actions/localization"));
37
+ var import_localizationTexts = __toESM(require("./actions/localizationTexts"));
38
+ var import_constans = require("./constans");
39
+ var import_resources = __toESM(require("./resources"));
40
+ var import_utils = require("./utils");
41
+ class LocalizationManagementPlugin extends import_server.Plugin {
42
+ resources;
43
+ registerUISchemahook(plugin) {
44
+ const uiSchemaStoragePlugin = plugin || this.app.getPlugin("ui-schema");
45
+ if (!uiSchemaStoragePlugin) {
46
+ return;
47
+ }
48
+ uiSchemaStoragePlugin.serverHooks.register("onSelfSave", "extractTextToLocale", async ({ schemaInstance }) => {
49
+ var _a;
50
+ const module2 = `resources.${import_constans.NAMESPACE_MENUS}`;
51
+ const schema = schemaInstance.get("schema");
52
+ const title = (schema == null ? void 0 : schema.title) || ((_a = schema == null ? void 0 : schema["x-component-props"]) == null ? void 0 : _a.title);
53
+ if (!title) {
54
+ return;
55
+ }
56
+ const result = await this.resources.filterExists([{ text: title, module: module2 }]);
57
+ if (!result.length) {
58
+ return;
59
+ }
60
+ this.db.getRepository("localizationTexts").create({
61
+ values: {
62
+ module: module2,
63
+ text: title
64
+ }
65
+ }).then((res) => this.resources.updateCacheTexts([res])).catch((err) => {
66
+ });
67
+ });
68
+ }
69
+ afterAdd() {
70
+ }
71
+ beforeLoad() {
72
+ }
73
+ async load() {
74
+ this.app.resourcer.define({
75
+ name: "localizationTexts",
76
+ actions: import_localizationTexts.default
77
+ });
78
+ this.app.resourcer.define({
79
+ name: "localization",
80
+ actions: import_localization.default
81
+ });
82
+ this.app.acl.registerSnippet({
83
+ name: `pm.${this.name}.localization`,
84
+ actions: ["localization:*", "localizationTexts:*", "localizationTranslations:*"]
85
+ });
86
+ this.db.on("afterSave", async (instance, options) => {
87
+ const module2 = `resources.${import_constans.NAMESPACE_COLLECTIONS}`;
88
+ const model = instance.constructor;
89
+ const collection = model.collection;
90
+ if (!collection) {
91
+ return;
92
+ }
93
+ let texts = [];
94
+ const fields = Array.from(collection.fields.values()).filter((field) => {
95
+ var _a;
96
+ return ((_a = field.options) == null ? void 0 : _a.translation) && instance["_changed"].has(field.name);
97
+ }).map((field) => field.name);
98
+ if (!fields.length) {
99
+ return;
100
+ }
101
+ const textsFromDB = (0, import_utils.getTextsFromDBRecord)(fields, instance);
102
+ textsFromDB.forEach((text) => {
103
+ texts.push({ text, module: module2 });
104
+ });
105
+ texts = await this.resources.filterExists(texts, options == null ? void 0 : options.transaction);
106
+ this.db.getModel("localizationTexts").bulkCreate(
107
+ texts.map(({ text, module: module3 }) => ({
108
+ module: module3,
109
+ text
110
+ })),
111
+ {
112
+ transaction: options == null ? void 0 : options.transaction
113
+ }
114
+ ).then((newTexts) => this.resources.updateCacheTexts(newTexts, options == null ? void 0 : options.transaction)).catch((err) => {
115
+ });
116
+ });
117
+ const cache = await this.app.cacheManager.createCache({
118
+ name: "localization",
119
+ prefix: "localization",
120
+ store: "memory"
121
+ });
122
+ this.resources = new import_resources.default(this.db, cache);
123
+ this.registerUISchemahook();
124
+ this.app.resourcer.use(async (ctx, next) => {
125
+ await next();
126
+ const { resourceName, actionName } = ctx.action;
127
+ if (resourceName === "app" && actionName === "getLang") {
128
+ const custom = await this.resources.getResources(ctx.get("X-Locale") || "en-US");
129
+ const appLang = ctx.body;
130
+ const resources = { ...appLang.resources };
131
+ Object.keys(custom).forEach((key) => {
132
+ const module2 = key.replace("resources.", "");
133
+ const resource = appLang.resources[module2];
134
+ const customResource = custom[key];
135
+ resources[module2] = resource ? (0, import_deepmerge.default)(resource, customResource) : customResource;
136
+ });
137
+ ctx.body = {
138
+ ...appLang,
139
+ resources
140
+ };
141
+ }
142
+ });
143
+ }
144
+ async install(options) {
145
+ }
146
+ async afterEnable() {
147
+ }
148
+ async afterDisable() {
149
+ const uiSchemaStoragePlugin = this.app.getPlugin("ui-schema");
150
+ if (!uiSchemaStoragePlugin) {
151
+ return;
152
+ }
153
+ uiSchemaStoragePlugin.serverHooks.remove("onSelfSave", "extractTextToLocale");
154
+ }
155
+ async remove() {
156
+ }
157
+ }
158
+ var plugin_default = LocalizationManagementPlugin;
159
+ // Annotate the CommonJS export names for ESM import in node:
160
+ 0 && (module.exports = {
161
+ LocalizationManagementPlugin
162
+ });
@@ -0,0 +1,19 @@
1
+ import { Cache } from '@tachybase/cache';
2
+ import { Database, Transaction } from '@tachybase/database';
3
+ export default class Resources {
4
+ cache: Cache;
5
+ db: Database;
6
+ constructor(db: Database, cache: Cache);
7
+ getTexts(transaction?: Transaction): Promise<any>;
8
+ getTranslations(locale: string): Promise<any>;
9
+ getResources(locale: string): Promise<{}>;
10
+ filterExists(texts: {
11
+ text: string;
12
+ module: string;
13
+ }[], transaction?: Transaction): Promise<{
14
+ text: string;
15
+ module: string;
16
+ }[]>;
17
+ updateCacheTexts(texts: any[], transaction?: Transaction): Promise<void>;
18
+ resetCache(locale: string): Promise<void>;
19
+ }
@@ -0,0 +1,86 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var resources_exports = {};
19
+ __export(resources_exports, {
20
+ default: () => Resources
21
+ });
22
+ module.exports = __toCommonJS(resources_exports);
23
+ class Resources {
24
+ cache;
25
+ db;
26
+ constructor(db, cache) {
27
+ this.cache = cache;
28
+ this.db = db;
29
+ }
30
+ async getTexts(transaction) {
31
+ return await this.cache.wrap(`texts`, async () => {
32
+ return await this.db.getRepository("localizationTexts").find({
33
+ fields: ["id", "module", "text"],
34
+ raw: true,
35
+ transaction
36
+ });
37
+ });
38
+ }
39
+ async getTranslations(locale) {
40
+ return await this.cache.wrap(`translations:${locale}`, async () => {
41
+ return await this.db.getRepository("localizationTranslations").find({
42
+ fields: ["textId", "translation"],
43
+ filter: { locale },
44
+ raw: true
45
+ });
46
+ });
47
+ }
48
+ async getResources(locale) {
49
+ const [texts, translations] = await Promise.all([this.getTexts(), this.getTranslations(locale)]);
50
+ const resources = {};
51
+ const textsMap = texts.reduce((map, item) => {
52
+ map[item.id] = item;
53
+ return map;
54
+ }, {});
55
+ translations.forEach((item) => {
56
+ const text = textsMap[item.textId];
57
+ if (!text) {
58
+ return;
59
+ }
60
+ const module2 = text.module;
61
+ if (!resources[module2]) {
62
+ resources[module2] = {};
63
+ }
64
+ resources[module2][text.text] = item.translation;
65
+ });
66
+ return resources;
67
+ }
68
+ async filterExists(texts, transaction) {
69
+ const existTexts = await this.getTexts(transaction);
70
+ return texts.filter((text) => {
71
+ return !existTexts.find((item) => item.text === text.text && item.module === text.module);
72
+ });
73
+ }
74
+ async updateCacheTexts(texts, transaction) {
75
+ const newTexts = texts.map((text) => ({
76
+ id: text.id,
77
+ module: text.module,
78
+ text: text.text
79
+ }));
80
+ const existTexts = await this.getTexts(transaction);
81
+ await this.cache.set(`texts`, [...existTexts, ...newTexts]);
82
+ }
83
+ async resetCache(locale) {
84
+ await this.cache.del(`translations:${locale}`);
85
+ }
86
+ }
@@ -0,0 +1,3 @@
1
+ export declare const compile: (title: string) => string;
2
+ export declare const getTextsFromUISchema: (schema: any) => any[];
3
+ export declare const getTextsFromDBRecord: (fields: string[], record: any) => any[];
@@ -0,0 +1,79 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var utils_exports = {};
19
+ __export(utils_exports, {
20
+ compile: () => compile,
21
+ getTextsFromDBRecord: () => getTextsFromDBRecord,
22
+ getTextsFromUISchema: () => getTextsFromUISchema
23
+ });
24
+ module.exports = __toCommonJS(utils_exports);
25
+ const compile = (title) => (title || "").replace(/{{\s*t\(["|'|`](.*)["|'|`]\)\s*}}/g, "$1");
26
+ const getTextsFromUISchema = (schema) => {
27
+ var _a, _b, _c, _d;
28
+ const texts = [];
29
+ const title = compile(schema.title);
30
+ const componentPropsTitle = compile((_a = schema["x-component-props"]) == null ? void 0 : _a.title);
31
+ const decoratorPropsTitle = compile((_b = schema["x-decorator-props"]) == null ? void 0 : _b.title);
32
+ if (title) {
33
+ texts.push(title);
34
+ }
35
+ if (componentPropsTitle) {
36
+ texts.push(componentPropsTitle);
37
+ }
38
+ if (decoratorPropsTitle) {
39
+ texts.push(decoratorPropsTitle);
40
+ }
41
+ if ((_d = (_c = schema["x-data-templates"]) == null ? void 0 : _c.items) == null ? void 0 : _d.length) {
42
+ schema["x-data-templates"].items.forEach((item) => {
43
+ const title2 = compile(item.title);
44
+ if (title2) {
45
+ texts.push(title2);
46
+ }
47
+ });
48
+ }
49
+ return texts;
50
+ };
51
+ const getTextsFromDBRecord = (fields, record) => {
52
+ const texts = [];
53
+ fields.forEach((field) => {
54
+ var _a, _b;
55
+ const value = record[field];
56
+ if (typeof value === "string") {
57
+ texts.push(compile(value));
58
+ }
59
+ if (typeof value === "object") {
60
+ if ((_a = value == null ? void 0 : value.uiSchema) == null ? void 0 : _a.title) {
61
+ texts.push(compile(value.uiSchema.title));
62
+ }
63
+ if ((_b = value == null ? void 0 : value.uiSchema) == null ? void 0 : _b.enum) {
64
+ value.uiSchema.enum.forEach((item) => {
65
+ if (item == null ? void 0 : item.label) {
66
+ texts.push(compile(item.label));
67
+ }
68
+ });
69
+ }
70
+ }
71
+ });
72
+ return texts;
73
+ };
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ compile,
77
+ getTextsFromDBRecord,
78
+ getTextsFromUISchema
79
+ });
@@ -0,0 +1,156 @@
1
+ {
2
+ "info": {
3
+ "title": "TachyBase API - Localization management plugin"
4
+ },
5
+ "openapi": "3.0.2",
6
+ "paths": {
7
+ "/localization:sync": {
8
+ "post": {
9
+ "tags": ["localization"],
10
+ "description": "Synchronize localization resources",
11
+ "parameters": [
12
+ {
13
+ "name": "X-Locale",
14
+ "in": "header",
15
+ "defalut": "en-US",
16
+ "schema": {
17
+ "type": "string"
18
+ }
19
+ }
20
+ ],
21
+ "requestBody": {
22
+ "content": {
23
+ "application/json": {
24
+ "schema": {
25
+ "type": "object",
26
+ "properties": {
27
+ "type": {
28
+ "type": "array",
29
+ "items": {
30
+ "type": "string",
31
+ "enum": ["local", "menu", "db"]
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
37
+ }
38
+ },
39
+ "responses": {
40
+ "200": {
41
+ "description": "OK"
42
+ }
43
+ }
44
+ }
45
+ },
46
+ "/localization:publish": {
47
+ "post": {
48
+ "tags": ["localization"],
49
+ "description": "Publish localization resources (Reset cache)",
50
+ "parameters": [
51
+ {
52
+ "name": "X-Locale",
53
+ "in": "header",
54
+ "defalut": "en-US",
55
+ "schema": {
56
+ "type": "string"
57
+ }
58
+ }
59
+ ],
60
+ "responses": {
61
+ "200": {
62
+ "description": "OK"
63
+ }
64
+ }
65
+ }
66
+ },
67
+ "/localizationTexts:list": {
68
+ "get": {
69
+ "tags": ["localizationTexts"],
70
+ "description": "Retrive localization texts with translations",
71
+ "parameters": [
72
+ {
73
+ "name": "X-Locale",
74
+ "in": "header",
75
+ "defalut": "en-US",
76
+ "schema": {
77
+ "type": "string"
78
+ }
79
+ },
80
+ {
81
+ "name": "keyword",
82
+ "in": "query",
83
+ "description": "Search keyword",
84
+ "schema": {
85
+ "type": "string"
86
+ }
87
+ },
88
+ {
89
+ "name": "hasTranslation",
90
+ "in": "query",
91
+ "description": "true - list all, false - list only untranslated",
92
+ "schema": {
93
+ "type": "boolean"
94
+ },
95
+ "defalut": true
96
+ }
97
+ ],
98
+ "responses": {
99
+ "200": {
100
+ "description": "OK"
101
+ }
102
+ }
103
+ }
104
+ },
105
+ "/localizationTranslations:updateOrCreate": {
106
+ "post": {
107
+ "tags": ["localizationTranslations"],
108
+ "description": "Update or create localization translations",
109
+ "parameters": [
110
+ {
111
+ "name": "textId",
112
+ "in": "query",
113
+ "schema": {
114
+ "type": "integer"
115
+ },
116
+ "required": true
117
+ },
118
+ {
119
+ "name": "locale",
120
+ "in": "query",
121
+ "schema": {
122
+ "type": "string"
123
+ },
124
+ "required": true
125
+ }
126
+ ],
127
+ "requestBody": {
128
+ "content": {
129
+ "application/json": {
130
+ "schema": {
131
+ "type": "object",
132
+ "properties": {
133
+ "textId": {
134
+ "type": "integer"
135
+ },
136
+ "locale": {
137
+ "type": "string"
138
+ },
139
+ "translation": {
140
+ "type": "string"
141
+ }
142
+ }
143
+ }
144
+ }
145
+ }
146
+ },
147
+ "responses": {
148
+ "200": {
149
+ "description": "OK"
150
+ }
151
+ }
152
+ }
153
+ }
154
+ },
155
+ "tags": []
156
+ }
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@tachybase/plugin-i18n-editor",
3
+ "displayName": "Localization",
4
+ "version": "0.23.8",
5
+ "description": "Allows to manage localization resources of the application.",
6
+ "keywords": [
7
+ "System management"
8
+ ],
9
+ "license": "Apache-2.0",
10
+ "main": "dist/server/index.js",
11
+ "devDependencies": {
12
+ "@ant-design/icons": "^5.5.2",
13
+ "ahooks": "^3.8.4",
14
+ "antd": "5.22.5",
15
+ "deepmerge": "^4.3.1",
16
+ "react-i18next": "^15.2.0",
17
+ "@tachybase/schema": "0.23.8"
18
+ },
19
+ "peerDependencies": {
20
+ "@tachybase/actions": "0.23.8",
21
+ "@tachybase/client": "0.23.8",
22
+ "@tachybase/server": "0.23.8",
23
+ "@tachybase/test": "0.23.8",
24
+ "@tachybase/cache": "0.23.8",
25
+ "@tachybase/database": "0.23.8",
26
+ "@tachybase/module-ui-schema": "0.23.8",
27
+ "@tachybase/module-web": "0.23.8"
28
+ },
29
+ "description.zh-CN": "支持管理应用程序的本地化资源。",
30
+ "displayName.zh-CN": "本地化",
31
+ "scripts": {
32
+ "build": "tachybase-build --no-dts @tachybase/plugin-i18n-editor"
33
+ }
34
+ }
package/server.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ // @ts-nocheck
2
+ export * from './dist/server';
3
+ export { default } from './dist/server';