Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xliff

Package Overview
Dependencies
Maintainers
2
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xliff

xliff2js and js2xliff converter xliff utils

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
44K
decreased by-10.32%
Maintainers
2
Weekly downloads
 
Created
Source

travis npm

Download

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

npm install --save xliff

You can then require() xliff as normal:

const xliff = require('xliff');

Or you can direclty require() its functions:

const xliff2js = require('xliff/xliff2js');

Usage

XLIFF 2.0

const xliff = `<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="en-US" trgLang="de-CH">
  <file id="namespace1">
    <unit id="key1">
      <segment>
        <source>Hello</source>
        <target>Hallo</target>
      </segment>
    </unit>
    <unit id="key2">
      <segment>
        <source>An application to manipulate and process XLIFF documents</source>
        <target>Eine Applikation um XLIFF Dokumente zu manipulieren und verarbeiten</target>
      </segment>
    </unit>
    <unit id="key.nested">
      <segment>
        <source>XLIFF Data Manager</source>
        <target>XLIFF Daten Manager</target>
      </segment>
    </unit>
  </file>
</xliff>`;

const js = {
  "resources": {
    "namespace1": {
      "key1": {
        "source": "Hello",
        "target": "Hallo"
      },
      "key2": {
        "source": "An application to manipulate and process XLIFF documents",
        "target": "Eine Applikation um XLIFF Dokumente zu manipulieren und verarbeiten"
      },
      "key.nested": {
        "source": "XLIFF Data Manager",
        "target": "XLIFF Daten Manager"
      }
    }
  },
  "sourceLanguage": "en-US",
  "targetLanguage": "de-CH"
};

const xliff2js = require('xliff/xliff2js');
xliff2js(xliff, (err, res) => {
  // res is like js
});

const js2kliff = require('xliff/js2kliff');
js2kliff(js, (err, res) => {
  // res is like xliff
});

const targetOfjs = require('xliff/targetOfjs');
targetOfjs(js, (err, res) => {
  // res is:
  // {
  //   "key1": "Hallo",
  //   "key2": "Eine Applikation um XLIFF Dokumente zu manipulieren und verarbeiten",
  //   "key.nested": "XLIFF Daten Manager"
  // }
});

const sourceOfjs = require('xliff/sourceOfjs');
sourceOfjs(js, (err, res) => {
  // res is:
  // {
  //   "key1": "Hello",
  //   "key2": "An application to manipulate and process XLIFF documents",
  //   "key.nested": "XLIFF Data Manager"
  // }
});

const createjs = require('xliff/createjs');
createjs(
  js.sourceLanguage,
  js.targetLanguage,
  {
    "key1": "Hello",
    "key2": "An application to manipulate and process XLIFF documents",
    "key.nested": "XLIFF Data Manager"
  },
  {
    "key1": "Hallo",
    "key2": "Eine Applikation um XLIFF Dokumente zu manipulieren und verarbeiten",
    "key.nested": "XLIFF Daten Manager"
  }
  'namespace1',
  (err, res) => {
  // res is like js
});

const createkliff = require('xliff/createkliff');
createkliff(
  js.sourceLanguage,
  js.targetLanguage,
  {
    "key1": "Hello",
    "key2": "An application to manipulate and process XLIFF documents",
    "key.nested": "XLIFF Data Manager"
  },
  {
    "key1": "Hallo",
    "key2": "Eine Applikation um XLIFF Dokumente zu manipulieren und verarbeiten",
    "key.nested": "XLIFF Daten Manager"
  }
  'namespace1',
  (err, res) => {
  // res is like xliff
});
XLIFF 1.2

  const xliff = `<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd" version="1.2" srcLang="en-US" trgLang="de-CH">
    <file original="namespace1">
      <body>
        <trans-unit id="key1">
          <source>Hello</source>
          <target>Hallo</target>
        </trans-unit>
        <trans-unit id="key2">
          <source>An application to manipulate and process XLIFF documents</source>
          <target>Eine Applikation um XLIFF Dokumente zu manipulieren und verarbeiten</target>
        </trans-unit>
        <trans-unit id="key.nested">
          <source>XLIFF Data Manager</source>
          <target>XLIFF Daten Manager</target>
        </trans-unit>
      </body>
    </file>
  </xliff>`

  const js = {
    "resources": {
      "namespace1": {
        "key1": {
          "source": "Hello",
          "target": "Hallo"
        },
        "key2": {
          "source": "An application to manipulate and process XLIFF documents",
          "target": "Eine Applikation um XLIFF Dokumente zu manipulieren und verarbeiten"
        },
        "key.nested": {
          "source": "XLIFF Data Manager",
          "target": "XLIFF Daten Manager"
        }
      }
    },
    "sourceLanguage": "en-US",
    "targetLanguage": "de-CH"
  }

  const xliff12ToJs = require('xliff/xliff12ToJs');
  xliff12ToJs(xliff, (err, res) => {
    // res is like js
  });

  const jsToXliff12 = require('xliff/jsToXliff12');
  jsToXliff12(js, (err, res) => {
    // res is like xliff
  });


Keywords

FAQs

Package last updated on 21 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc