@transifex/native 3.0.0 → 3.2.1
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/README.md +83 -0
- package/dist/browser.native.js +2 -2
- package/dist/browser.native.js.map +1 -1
- package/dist/node.native.d.ts +20 -0
- package/dist/node.native.js +2 -2
- package/dist/node.native.js.map +1 -1
- package/package.json +1 -1
- package/src/TxNative.js +116 -1
- package/src/index.d.ts +20 -0
- package/src/utils.js +14 -0
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@ Related packages:
|
|
|
10
10
|
* [@transifex/react](https://www.npmjs.com/package/@transifex/react)
|
|
11
11
|
* [@transifex/cli](https://www.npmjs.com/package/@transifex/cli)
|
|
12
12
|
|
|
13
|
+
Learn more about Transifex Native in the [Transifex Developer Hub](https://developers.transifex.com/docs/native).
|
|
14
|
+
|
|
13
15
|
# Upgrade to v2
|
|
14
16
|
|
|
15
17
|
If you are upgrading from the `1.x.x` version, please read this [migration guide](https://github.com/transifex/transifex-javascript/blob/HEAD/UPGRADE_TO_V2.md), as there are breaking changes in place.
|
|
@@ -243,6 +245,87 @@ const html = t('<b>Hello {username}</b>', {
|
|
|
243
245
|
});
|
|
244
246
|
```
|
|
245
247
|
|
|
248
|
+
## Push source content
|
|
249
|
+
|
|
250
|
+
For server side integrations you can also push source content programmatically
|
|
251
|
+
without using the CLI.
|
|
252
|
+
|
|
253
|
+
```js
|
|
254
|
+
tx.pushSource(payload, params): Promise
|
|
255
|
+
payload: Object({
|
|
256
|
+
key: {
|
|
257
|
+
string: String,
|
|
258
|
+
meta: {
|
|
259
|
+
context: String,
|
|
260
|
+
developer_comment: String,
|
|
261
|
+
character_limit: Number,
|
|
262
|
+
tags: Array(String),
|
|
263
|
+
occurrences: Array(String),
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
key: { .. }
|
|
267
|
+
})
|
|
268
|
+
params: Object({
|
|
269
|
+
// Replace the entire resource content with the pushed content of this request
|
|
270
|
+
purge: Boolean,
|
|
271
|
+
|
|
272
|
+
// Replace the existing string tags with the tags of this request
|
|
273
|
+
overrideTags: Boolean,
|
|
274
|
+
|
|
275
|
+
// If true, when wait for processing to be complete before
|
|
276
|
+
// resolving this promise
|
|
277
|
+
noWait: Boolean,
|
|
278
|
+
})
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
For example:
|
|
282
|
+
|
|
283
|
+
```js
|
|
284
|
+
const { createNativeInstance } = require('@transifex/native');
|
|
285
|
+
|
|
286
|
+
const tx = createNativeInstance({
|
|
287
|
+
token: 'token',
|
|
288
|
+
secret: 'secret',
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
await tx.pushSource({
|
|
292
|
+
'mykey': {
|
|
293
|
+
string: 'My string',
|
|
294
|
+
meta: {
|
|
295
|
+
context: 'content', // optional
|
|
296
|
+
developer_comment: 'developer comment', // optional
|
|
297
|
+
character_limit: 10, // optional
|
|
298
|
+
tags: ['tag1', 'tag2'], // optional
|
|
299
|
+
occurrences: ['file.jsx', 'file2.js'], // optional
|
|
300
|
+
},
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Invalidate CDS cache
|
|
306
|
+
|
|
307
|
+
Server side integrations can also invalidate the CDS cache programmatically.
|
|
308
|
+
|
|
309
|
+
```js
|
|
310
|
+
tx.invalidateCDS({
|
|
311
|
+
// if true, then purge the cache entirely (not recommended)
|
|
312
|
+
purge: Boolean,
|
|
313
|
+
}): Promise
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
For example:
|
|
317
|
+
|
|
318
|
+
```js
|
|
319
|
+
const { createNativeInstance } = require('@transifex/native');
|
|
320
|
+
|
|
321
|
+
const tx = createNativeInstance({
|
|
322
|
+
token: 'token',
|
|
323
|
+
secret: 'secret',
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
await tx.invalidateCDS();
|
|
327
|
+
```
|
|
328
|
+
|
|
246
329
|
## Events
|
|
247
330
|
|
|
248
331
|
Library for listening to various async events.
|