@transifex/native 2.2.0-alpha.0 → 2.3.2
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 +29 -0
- package/dist/browser.native.js +2 -2
- package/dist/browser.native.js.map +1 -1
- package/dist/node.native.d.ts +1 -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 +74 -3
- package/src/index.d.ts +1 -0
- package/src/index.js +10 -0
package/README.md
CHANGED
|
@@ -266,6 +266,35 @@ offEvent(type, function)
|
|
|
266
266
|
sendEvent(type, payload, caller)
|
|
267
267
|
```
|
|
268
268
|
|
|
269
|
+
## Using more than one TX Native instances
|
|
270
|
+
|
|
271
|
+
```js
|
|
272
|
+
const { tx, t, createNativeInstance } = require('@transifex/native');
|
|
273
|
+
|
|
274
|
+
// Initiatate a secondary TX Instance
|
|
275
|
+
const txOtherInstance = createNativeInstance();
|
|
276
|
+
txOtherInstance.init({
|
|
277
|
+
token: '<PUBLIC PROJECT TOKEN 2>',
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
// initialize SDK
|
|
281
|
+
tx.init({
|
|
282
|
+
token: '<PUBLIC PROJECT TOKEN>',
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
// Use tx as a controller of the other instance
|
|
286
|
+
tx.controllerOf(txOtherInstance);
|
|
287
|
+
|
|
288
|
+
// get all languages
|
|
289
|
+
tx.setCurrentLocale('fr').then(function() {
|
|
290
|
+
// translate something
|
|
291
|
+
const message = t('Welcome {user}', {user: 'Joe'});
|
|
292
|
+
console.log(message);
|
|
293
|
+
const message2 = txOtherInstance.t('Welcome {user}', {user: 'Joe'});
|
|
294
|
+
console.log(message2);
|
|
295
|
+
});
|
|
296
|
+
```
|
|
297
|
+
|
|
269
298
|
# License
|
|
270
299
|
|
|
271
300
|
Licensed under Apache License 2.0, see [LICENSE](https://github.com/transifex/transifex-javascript/blob/HEAD/LICENSE) file.
|