npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tmexchange

v2.0.5

Published

tmx2js and js2tmx converter tmx utils

Downloads

112,238

Readme

travis npm

Download

The source is available for download from GitHub. Alternatively, you can install using npm:

npm install --save tmexchange

You can then import or require() tmexchange as normal:

import tmx from 'tmexchange'
// or
const tmx = require('tmexchange')

tmx.tmx2js(xml, (err, res) => {})

Or you can direclty import or require() its functions:

import js2tmx from 'tmexchange/js2tmx'
// or
const js2tmx = require('tmexchange/cjs/js2tmx')

Usage

TMX

const tmx = `<tmx version="1.4b">
 <header creationtool="XYZTool" creationtoolversion="1.01-023"
  datatype="PlainText" segtype="sentence"
  adminlang="en-US" srclang="en-US"
  o-tmf="ABCTransMem">
 </header>
 <body>
  <tu tuid="key1">
   <prop type="group">namespace1</prop>
   <tuv xml:lang="en-US">
    <seg>Hello</seg>
   </tuv>
   <tuv xml:lang="de-CH">
    <seg>Hallo</seg>
   </tuv>
  </tu>
  <tu tuid="key2">
   <prop type="group">namespace1</prop>
   <tuv xml:lang="en-US">
    <seg>An application to manipulate and process TMX documents</seg>
   </tuv>
   <tuv xml:lang="de-CH">
    <seg>Eine Applikation um TMX Dokumente zu manipulieren und verarbeiten</seg>
   </tuv>
  </tu>
  <tu tuid="key.nested">
   <prop type="group">namespace1</prop>
   <tuv xml:lang="en-US">
    <seg>TMX Data Manager</seg>
   </tuv>
   <tuv xml:lang="de-CH">
    <seg>TMX Daten Manager</seg>
   </tuv>
  </tu>
 </body>
</tmx>`

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

const resJs = await tmx2js(xml)
const resXml = await js2tmx(js)
// or
tmx2js(xml).then((res) => {})
js2tmx(js).then((res) => {})