1 /**
2 * @oas [post] /admin/translations/batch
3 * operationId: PostTranslationsBatch
4 * summary: Manage Translations
5 * description: Manage translations in bulk by creating, updating, or deleting multiple translations in a single request. You can manage translations for various resources such as products, product
6 * variants, categories, and more.
7 * x-authenticated: true
8 * security:
9 * - api_token: []
10 * - cookie_auth: []
11 * - jwt_token: []
12 * requestBody:
13 * content:
14 * application/json:
15 * schema:
16 * type: object
17 * description: The translations to be created, updated, or deleted in bulk.
18 * properties:
19 * create:
20 * type: array
21 * description: The translations to create.
22 * items:
23 * $ref: "#/components/schemas/AdminCreateTranslation"
24 * update:
25 * type: array
26 * description: The translations to update.
27 * items:
28 * $ref: "#/components/schemas/AdminUpdateTranslation"
29 * delete:
30 * type: array
31 * description: The translations to delete.
32 * items:
33 * type: string
34 * title: delete
35 * description: The ID of a translation to delete.
36 * x-codeSamples:
37 * - lang: JavaScript
38 * label: JS SDK
39 * source: |-
40 * import Medusa from "@medusajs/js-sdk"
41 *
42 * export const sdk = new Medusa({
43 * baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
44 * debug: import.meta.env.DEV,
45 * auth: {
46 * type: "session",
47 * },
48 * })
49 *
50 * sdk.admin.translation.batch({
51 * create: [
52 * {
53 * reference_id: "prod_123",
54 * reference: "product",
55 * locale_code: "en-US",
56 * translations: { title: "Shirt" }
57 * }
58 * ],
59 * update: [
60 * {
61 * id: "trans_123",
62 * translations: { title: "Pants" }
63 * }
64 * ],
65 * delete: ["trans_321"]
66 * })
67 * .then(({ created, updated, deleted }) => {
68 * console.log(created, updated, deleted)
69 * })
70 * - lang: Shell
71 * label: cURL
72 * source: |-
73 * curl -X POST '{backend_url}/admin/translations/batch' \
74 * -H 'Authorization: Bearer {access_token}' \
75 * -H 'Content-Type: application/json' \
76 * -d '{
77 * "create": [
78 * {
79 * "reference": "product",
80 * "reference_id": "prod_123",
81 * "locale_code": "fr-FR",
82 * "translations": {
83 * "title": "Chaussures",
84 * "description": "Des chaussures élégantes."
85 * }
86 * }
87 * ]
88 * }'
89 * tags:
90 * - Translations
91 * responses:
92 * "200":
93 * description: OK
94 * content:
95 * application/json:
96 * schema:
97 * $ref: "#/components/schemas/AdminTranslationsBatchResponse"
98 * "400":
99 * $ref: "#/components/responses/400_error"
100 * "401":
101 * $ref: "#/components/responses/unauthorized"
102 * "404":
103 * $ref: "#/components/responses/not_found_error"
104 * "409":
105 * $ref: "#/components/responses/invalid_state_error"
106 * "422":
107 * $ref: "#/components/responses/invalid_request_error"
108 * "500":
109 * $ref: "#/components/responses/500_error"
110 * x-workflow: batchTranslationsWorkflow
111 * x-events:
112 * - name: translation.created
113 * payload: |-
114 * ```ts
115 * {
116 * id, // The ID of the translation
117 * }
118 * ```
119 * description: Emitted when translations are created.
120 * deprecated: false
121 * since: 2.12.3
122 * - name: translation.updated
123 * payload: |-
124 * ```ts
125 * {
126 * id, // The ID of the translation
127 * }
128 * ```
129 * description: Emitted when translations are updated.
130 * deprecated: false
131 * since: 2.12.3
132 * - name: translation.deleted
133 * payload: |-
134 * ```ts
135 * {
136 * id, // The ID of the translation
137 * }
138 * ```
139 * description: Emitted when translations are deleted.
140 * deprecated: false
141 * since: 2.12.3
142 * x-since: 2.12.3
143 * x-featureFlag: translation
144 *
145 */
146