https://github.com/locize/tmexchange
tmx2js and js2tmx converter tmx utils
https://github.com/locize/tmexchange
js json tmx translation
Last synced: 11 months ago
JSON representation
tmx2js and js2tmx converter tmx utils
- Host: GitHub
- URL: https://github.com/locize/tmexchange
- Owner: locize
- Created: 2017-08-16T20:53:29.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-05-24T07:06:02.000Z (about 3 years ago)
- Last Synced: 2025-06-06T04:45:22.488Z (12 months ago)
- Topics: js, json, tmx, translation
- Language: JavaScript
- Size: 351 KB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
[](https://travis-ci.org/locize/tmexchange) [](https://npmjs.org/package/tmexchange)
## Download
The source is available for download from
[GitHub](https://github.com/locize/tmexchange/archive/master.zip).
Alternatively, you can install using npm:
```sh
npm install --save tmexchange
```
You can then `import` or `require()` tmexchange as normal:
```js
import tmx from 'tmexchange'
// or
const tmx = require('tmexchange')
tmx.tmx2js(xml, (err, res) => {})
```
Or you can direclty `import` or `require()` its functions:
```js
import js2tmx from 'tmexchange/js2tmx'
// or
const js2tmx = require('tmexchange/cjs/js2tmx')
```
## Usage
##### TMX
```js
const tmx = `
namespace1
Hello
Hallo
namespace1
An application to manipulate and process TMX documents
Eine Applikation um TMX Dokumente zu manipulieren und verarbeiten
namespace1
TMX Data Manager
TMX Daten Manager
`
const js = {
"resources": {
"namespace1": {
"key1": {
"en-US": "Hello",
"de-CH": "Hallo"
},
"key2": {
"en-US": "An application to manipulate and process TMX documents",
"de-CH": "Eine Applikation um TMX Dokumente zu manipulieren und verarbeiten"
},
"key.nested": {
"en-US": "TMX Data Manager",
"de-CH": "TMX Daten Manager"
}
}
},
"sourceLanguage": "en-US",
"administrationLanguage": "en-US", // optional, default is sourceLanguage
"creationTool": "tmexchange", // optional default is tmexchange
"creationToolVersion": "1.0.0", // optional default is package.json version
"version": "1.4b", // optional, default 1.4b
"oTMF": "ABCTransMem", // optional, default ABCTransMem
"tuid": true, // optional, default true
"datatype": "PlainText" // optional, default PlainText
}
import js2tmx from 'tmexchange/js2tmx'
js2tmx(js, (err, res) => {
// res is like tmx
});
import tmx2js from 'tmexchange/tmx2js'
tmx2js(tmx, (err, res) => {
// res is like js
});
```
Omitting the callback returns a promise
```js
const resJs = await tmx2js(xml)
const resXml = await js2tmx(js)
// or
tmx2js(xml).then((res) => {})
js2tmx(js).then((res) => {})
```