generaltranslation 2.0.48 → 2.0.50

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -237,50 +237,6 @@ console.log(results); // [{ translation: "Hola", language: "es" }, { translation
237
237
 
238
238
  - A promise that resolves to an array of processed results.
239
239
 
240
- ### updateRemoteDictionary(updates)
241
-
242
- Pushes updates to a remotely cached translation dictionary.
243
-
244
- #### Parameters
245
-
246
- - `updates` (Update[]): An array of update objects. Each update can be of type `react` or `intl`.
247
-
248
- - **React Update**:
249
- - `type`: `'react'`
250
- - `data`: An object containing:
251
- - `children` (object | string): The React children content to be translated.
252
- - `targetLanguage` (string, optional): The target language for the translation.
253
- - `metadata` (Record<string, any>): Additional metadata for the translation process.
254
-
255
- - **Intl Update**:
256
- - `type`: `'intl'`
257
- - `data`: An object containing:
258
- - `content` (string): The string content to be translated.
259
- - `targetLanguage` (string, optional): The target language for the translation.
260
- - `metadata` (Record<string, any>): Additional metadata for the translation process.
261
-
262
- #### Returns
263
-
264
- - A promise that resolves to a boolean indicating success (`true`) or failure (`false`).
265
-
266
- #### Example
267
-
268
- ```js
269
- import { updateRemoteDictionary } from 'generaltranslation';
270
- const updates = [
271
- {
272
- type: 'react',
273
- data: {
274
- children: { type: 'div', props: { children: 'Hello, world' } },
275
- targetLanguage: 'es',
276
- metadata: { id: 'greeting' }
277
- }
278
- }
279
- ];
280
- const success = await updateRemoteDictionary(updates);
281
- console.log(success); // true or false
282
- ```
283
-
284
240
  ## Utility Functions
285
241
 
286
242
  ### getLanguageDirection
package/dist/index.d.ts CHANGED
@@ -81,11 +81,13 @@ declare class GT {
81
81
  */
82
82
  bundleTranslation(requests: Request[]): Promise<Array<any | null>>;
83
83
  /**
84
- *Pushes updates to a remotely cached translation dictionary.
85
- * @param updates - Array of updates with optional targetLanguage.
86
- * @returns A promise that resolves to a boolean indicating success or failure.
84
+ * Pushes updates to a remotely cached translation dictionary.
85
+ * @param {Update[]} updates - Array of updates with optional targetLanguage.
86
+ * @param {string} [projectID=this.projectID] - The ID of the project. Defaults to the instance's projectID.
87
+ * @param {boolean} [replace=false] - Whether to replace the existing dictionary. Defaults to false.
88
+ * @returns {Promise<string[]>} A promise that resolves to an array of strings indicating the result of each update.
87
89
  */
88
- updateRemoteDictionary(updates: Update[]): Promise<string[]>;
90
+ updateRemoteDictionary(updates: Update[], projectID?: string, replace?: boolean): Promise<string[]>;
89
91
  }
90
92
  export default GT;
91
93
  /**
package/dist/index.js CHANGED
@@ -104,13 +104,15 @@ class GT {
104
104
  });
105
105
  }
106
106
  /**
107
- *Pushes updates to a remotely cached translation dictionary.
108
- * @param updates - Array of updates with optional targetLanguage.
109
- * @returns A promise that resolves to a boolean indicating success or failure.
107
+ * Pushes updates to a remotely cached translation dictionary.
108
+ * @param {Update[]} updates - Array of updates with optional targetLanguage.
109
+ * @param {string} [projectID=this.projectID] - The ID of the project. Defaults to the instance's projectID.
110
+ * @param {boolean} [replace=false] - Whether to replace the existing dictionary. Defaults to false.
111
+ * @returns {Promise<string[]>} A promise that resolves to an array of strings indicating the result of each update.
110
112
  */
111
- updateRemoteDictionary(updates) {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- return (0, _updateRemoteDictionary_1.default)(this, updates);
113
+ updateRemoteDictionary(updates_1) {
114
+ return __awaiter(this, arguments, void 0, function* (updates, projectID = this.projectID, replace = false) {
115
+ return (0, _updateRemoteDictionary_1.default)(this, updates, projectID, replace);
114
116
  });
115
117
  }
116
118
  }
@@ -17,7 +17,7 @@ exports.default = _updateRemoteDictionary;
17
17
  * @returns {Promise<boolean>} A promise that resolves to an array of processed results.
18
18
  * @internal
19
19
  */
20
- function _updateRemoteDictionary(gt, updates) {
20
+ function _updateRemoteDictionary(gt, updates, projectID, replace) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
22
  try {
23
23
  const response = yield fetch(`${gt.baseURL}/update`, {
@@ -26,7 +26,9 @@ function _updateRemoteDictionary(gt, updates) {
26
26
  'Content-Type': 'application/json',
27
27
  'gtx-api-key': gt.apiKey,
28
28
  },
29
- body: JSON.stringify(updates)
29
+ body: JSON.stringify({
30
+ updates, projectID, replace
31
+ })
30
32
  });
31
33
  if (!response.ok) {
32
34
  throw new Error(`${response.status}: ${yield response.text()}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generaltranslation",
3
- "version": "2.0.48",
3
+ "version": "2.0.50",
4
4
  "description": "A language toolkit for AI developers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",