@nocobase/plugin-localization 2.1.0-beta.29 → 2.1.0-beta.32

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 (33) hide show
  1. package/client-v2.d.ts +2 -0
  2. package/client-v2.js +1 -0
  3. package/dist/ai/ai-employees/lina.d.ts +10 -0
  4. package/dist/ai/ai-employees/lina.js +60 -0
  5. package/dist/client/300.3a4b9b688d36da96.js +10 -0
  6. package/dist/client/i18n-missing-handler.d.ts +1 -17
  7. package/dist/client/index.js +1 -1
  8. package/dist/client-v2/796.b9d793cda3c8b932.js +10 -0
  9. package/dist/client-v2/common/constants.d.ts +13 -0
  10. package/dist/client-v2/common/i18n-missing-handler.d.ts +23 -0
  11. package/dist/{client/Localization.d.ts → client-v2/i18n-missing-handler.d.ts} +1 -2
  12. package/dist/client-v2/index.d.ts +9 -0
  13. package/dist/client-v2/index.js +10 -0
  14. package/dist/client-v2/locale.d.ts +11 -0
  15. package/dist/client-v2/pages/LocalizationPage.d.ts +11 -0
  16. package/dist/client-v2/plugin.d.ts +13 -0
  17. package/dist/externalVersion.js +16 -12
  18. package/dist/locale/en-US.json +15 -1
  19. package/dist/locale/zh-CN.json +15 -1
  20. package/dist/server/actions/aiTranslate.d.ts +14 -0
  21. package/dist/server/actions/aiTranslate.js +127 -0
  22. package/dist/server/actions/localization.js +30 -15
  23. package/dist/server/actions/localizationTexts.js +8 -9
  24. package/dist/server/migrations/20260511230000-delete-official-plugin-package-resource-modules.d.ts +14 -0
  25. package/dist/server/migrations/20260511230000-delete-official-plugin-package-resource-modules.js +64 -0
  26. package/dist/server/plugin.d.ts +5 -2
  27. package/dist/server/plugin.js +72 -14
  28. package/dist/server/tasks/localization-ai-translate.d.ts +31 -0
  29. package/dist/server/tasks/localization-ai-translate.js +596 -0
  30. package/package.json +7 -2
  31. package/dist/client/304.6a0dd0c975aa0b7c.js +0 -10
  32. package/dist/server/source-manager.d.ts +0 -35
  33. package/dist/server/source-manager.js +0 -77
@@ -1,35 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
- import { Context } from '@nocobase/actions';
10
- import { Database } from '@nocobase/database';
11
- import { Registry } from '@nocobase/utils';
12
- export type Source = {
13
- title: string;
14
- sync: (ctx: Context) => Promise<{
15
- [module: string]: {
16
- [text: string]: string;
17
- };
18
- }>;
19
- namespace?: string;
20
- collections?: {
21
- collection: string;
22
- fields: string[];
23
- }[];
24
- };
25
- export declare class SourceManager {
26
- sources: Registry<Source>;
27
- registerSource(name: string, source: Source): void;
28
- sync(ctx: Context, types: string[]): Promise<{
29
- [module: string]: any;
30
- }>;
31
- handleTextsSaved(db: Database, handler: (texts: {
32
- text: string;
33
- module: string;
34
- }[], options?: any) => Promise<any>): void;
35
- }
@@ -1,77 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- var __defProp = Object.defineProperty;
11
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
- var __getOwnPropNames = Object.getOwnPropertyNames;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var source_manager_exports = {};
28
- __export(source_manager_exports, {
29
- SourceManager: () => SourceManager
30
- });
31
- module.exports = __toCommonJS(source_manager_exports);
32
- var import_utils = require("@nocobase/utils");
33
- class SourceManager {
34
- sources = new import_utils.Registry();
35
- registerSource(name, source) {
36
- this.sources.register(name, source);
37
- }
38
- async sync(ctx, types) {
39
- const resources = { client: {} };
40
- const sources = Array.from(this.sources.getKeys());
41
- const syncSources = sources.filter((source) => types.includes(source));
42
- const promises = syncSources.map((source) => this.sources.get(source).sync(ctx));
43
- const results = await Promise.all(promises);
44
- return results.reduce((result, resource) => {
45
- return { ...result, ...resource };
46
- }, resources);
47
- }
48
- handleTextsSaved(db, handler) {
49
- const sources = this.sources;
50
- for (const source of sources.getValues()) {
51
- if (!source.collections) {
52
- continue;
53
- }
54
- for (const { collection, fields } of source.collections) {
55
- db.on(`${collection}.afterSave`, async (instance, options) => {
56
- const texts = [];
57
- const changedFields = fields.filter((field) => instance["_changed"].has(field));
58
- if (!changedFields.length) {
59
- return;
60
- }
61
- changedFields.forEach((field) => {
62
- const text = instance.get(field);
63
- if (!text) {
64
- return;
65
- }
66
- texts.push({ text, module: `resources.${source.namespace}` });
67
- });
68
- await handler(texts, options);
69
- });
70
- }
71
- }
72
- }
73
- }
74
- // Annotate the CommonJS export names for ESM import in node:
75
- 0 && (module.exports = {
76
- SourceManager
77
- });