@justanarthur/payload-plugin-translator 1.3.21 → 3.1.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/dist/types.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import { CollectionSlug, GlobalSlug } from "payload";
2
2
  import { PayloadRequest } from "payload";
3
3
  type TranslateResolverArgs = {
4
- /** Locale to translate from */
5
4
  localeFrom: string;
6
- /** Locale to translate to */
7
5
  localeTo: string;
8
6
  req: PayloadRequest;
9
7
  texts: string[];
@@ -19,48 +17,20 @@ type TranslateResolver = {
19
17
  resolve: (args: TranslateResolverArgs) => Promise<TranslateResolverResponse> | TranslateResolverResponse;
20
18
  };
21
19
  type TranslatorConfig = {
22
- /**
23
- * Collections with the enabled translator in the admin UI
24
- */
25
20
  collections: CollectionSlug[];
26
- /**
27
- * Disable the plugin
28
- */
29
21
  disabled?: boolean;
30
- /**
31
- * Globals with the enabled translator in the admin UI
32
- */
33
22
  globals: GlobalSlug[];
34
- /**
35
- * Add resolvers that you want to include, examples on how to write your own in ./plugin/src/resolvers
36
- */
37
23
  resolvers: TranslateResolver[];
38
- /**
39
- * Auto-translate every save in the default locale to the other
40
- * configured locales via Payload's job queue.
41
- *
42
- * When `true`, the plugin:
43
- * - registers `createTranslateTask()` and `createTranslateWorkflow()`
44
- * in `config.jobs` (idempotent — skips if a task/workflow with
45
- * the same slug is already registered, so host-customized
46
- * factories survive),
47
- * - prepends `createAutoTranslateCollectionHook` /
48
- * `createAutoTranslateGlobalHook` to each collection/global
49
- * listed in `collections` / `globals`.
50
- *
51
- * Default: `false`. Public factories stay exported for hosts that
52
- * need per-entity control.
53
- */
54
24
  autoTranslate?: boolean;
55
25
  /**
56
- * Advanced traversal options. Mirrors the options accepted by the
57
- * internal field walker keep in sync if you need the latest shape.
26
+ * what a publish in the default locale does to the other locales.
27
+ * `missing` (default) fills empty fields and keeps existing translations and slugs;
28
+ * `all` re-translates every field.
58
29
  */
30
+ autoTranslateMode?: "all" | "missing";
31
+ /** adds the /admin/translations review view, its endpoints and the status collection (default true) */
32
+ review?: boolean;
59
33
  _options?: {
60
- /**
61
- * Hook invoked while walking each rich-text node. Lets you append
62
- * extra text segments to be translated (e.g. custom lexical nodes).
63
- */
64
34
  additionalTraverseRichText?: (args: {
65
35
  onText: (siblingData: Record<string, unknown>, attribute?: string) => void;
66
36
  root: Record<string, unknown>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justanarthur/payload-plugin-translator",
3
3
  "description": "Translator plugin for Payload CMS — automatic localization via Google, OpenAI, LibreTranslate, or custom resolvers.",
4
- "version": "1.3.21",
4
+ "version": "3.1.0",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "files": [
@@ -29,6 +29,12 @@
29
29
  "default": "./dist/types.js"
30
30
  }
31
31
  },
32
+ "./rsc": {
33
+ "import": {
34
+ "types": "./dist/rsc.d.ts",
35
+ "default": "./dist/rsc.js"
36
+ }
37
+ },
32
38
  "./client": {
33
39
  "import": {
34
40
  "types": "./dist/client.d.ts",
@@ -65,16 +71,20 @@
65
71
  "default": "./dist/resolvers/google.js"
66
72
  }
67
73
  },
74
+ "./client.css": "./dist/client.css",
68
75
  "./package.json": "./package.json"
69
76
  },
70
77
  "license": "MIT",
71
- "sideEffects": false,
78
+ "sideEffects": [
79
+ "**/*.css"
80
+ ],
72
81
  "engines": {
73
82
  "node": ">=20"
74
83
  },
75
84
  "scripts": {
76
- "build": "bunup",
85
+ "build": "NODE_ENV=production bunup",
77
86
  "clean": "rm -rf dist .tsbuildinfo",
87
+ "test": "bun test",
78
88
  "prepublishOnly": "bun run clean && bun run build"
79
89
  },
80
90
  "dependencies": {
@@ -82,18 +92,20 @@
82
92
  "he": "^1.2.0"
83
93
  },
84
94
  "devDependencies": {
85
- "@payloadcms/translations": "3.85.0",
86
- "@payloadcms/ui": "3.85.0",
95
+ "@payloadcms/next": "3.88.0",
96
+ "@payloadcms/translations": "3.88.0",
97
+ "@payloadcms/ui": "3.88.0",
87
98
  "@types/he": "^1.2.3",
88
- "@types/react": "19.2.14",
89
- "@types/react-dom": "19.2.3",
99
+ "@types/react": "19.2.18",
100
+ "@types/react-dom": "19.2.7",
90
101
  "bunup": "^0.16.32",
91
- "payload": "3.85.0",
92
- "react": "19.2.6",
93
- "react-dom": "19.2.6",
94
- "typescript": "5.7.3"
102
+ "payload": "3.88.0",
103
+ "react": "19.2.8",
104
+ "react-dom": "19.2.8",
105
+ "typescript": "^7.0.2"
95
106
  },
96
107
  "peerDependencies": {
108
+ "@payloadcms/next": "^3.85.0",
97
109
  "@payloadcms/translations": "^3.85.0",
98
110
  "@payloadcms/ui": "^3.85.0",
99
111
  "payload": "^3.85.0",
@@ -1,5 +0,0 @@
1
- .translator__custom-save-button {
2
- display: flex;
3
- align-items: center;
4
- gap: 10px;
5
- }
@@ -1,76 +0,0 @@
1
- .translator {
2
- &__modal {
3
- display: flex;
4
- position: relative;
5
- justify-content: center;
6
- align-items: center;
7
- width: fit-content;
8
- height: fit-content;
9
- }
10
-
11
- &__wrapper {
12
- display: flex;
13
- position: relative;
14
- flex-direction: column;
15
- gap: var(--base);
16
- z-index: 1;
17
- background: var(--theme-elevation-50);
18
- padding: 50px;
19
- }
20
-
21
- &__content {
22
- display: flex;
23
- flex-direction: column;
24
- align-items: center;
25
- gap: var(--base);
26
- max-width: 400px;
27
-
28
- h2 {
29
- margin: 0;
30
- text-align: center;
31
- }
32
- }
33
-
34
- &__buttons {
35
- display: flex;
36
- justify-content: center;
37
- gap: 10px;
38
- width: 100%;
39
-
40
- button {
41
- margin: 0;
42
- }
43
- }
44
-
45
- &__close {
46
- position: absolute;
47
- top: 10px;
48
- right: 10px;
49
- transition: 0.25s;
50
- cursor: pointer;
51
- width: 32px;
52
- height: 32px;
53
-
54
- &:hover {
55
- opacity: 0.6;
56
- }
57
-
58
- &:before,
59
- &:after {
60
- position: absolute;
61
- left: 15px;
62
- background-color: var(--theme-elevation-800);
63
- width: 2px;
64
- height: 33px;
65
- content: ' ';
66
- }
67
-
68
- &:before {
69
- transform: rotate(45deg);
70
- }
71
-
72
- &:after {
73
- transform: rotate(-45deg);
74
- }
75
- }
76
- }