Socket
Socket
Sign inDemoInstall

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 - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

test/fixtures/example_note.json

12

js2xliff.js

@@ -38,2 +38,9 @@ const xml2js = require('xml2js');

Object.keys(obj.resources[nsName]).forEach((k) => {
const segment = {
source: obj.resources[nsName][k].source,
target: obj.resources[nsName][k].target
};
if ('note' in obj.resources[nsName][k]) {
segment.note = obj.resources[nsName][k].note;
}
const u = {

@@ -43,6 +50,3 @@ $: {

},
segment: {
source: obj.resources[nsName][k].source,
target: obj.resources[nsName][k].target
}
segment
};

@@ -49,0 +53,0 @@ f.unit.push(u);

@@ -52,2 +52,5 @@ const xml2js = require('xml2js');

};
if ('note' in obj.resources[nsName][k]) {
u.note = obj.resources[nsName][k].note;
}
f.body['trans-unit'].push(u);

@@ -54,0 +57,0 @@ });

{
"name": "xliff",
"version": "1.0.1",
"version": "1.1.0",
"description": "xliff2js and js2xliff converter xliff utils",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -18,3 +18,8 @@ const fs = require('fs');

js_target: require('./example_multi_target.json')
},
example_note: {
js: require('./example_note.json'),
xliff: fs.readFileSync(path.join(__dirname, 'example_note.xliff')).toString().replace(/\n$/, ''),
xliff12: fs.readFileSync(path.join(__dirname, 'example_note12.xliff')).toString().replace(/\n$/, ''),
}
};

@@ -154,1 +154,47 @@ const expect = require('expect.js');

});
describe('with notes', () => {
test('xliff2js', (fn) => (done) => {
fn(fixtures.example_note.xliff, (err, res) => {
expect(err).not.to.be.ok();
expect(res).to.eql(fixtures.example_note.js);
done();
});
});
test('xliff12ToJs', (fn) => (done) => {
fn(fixtures.example_note.xliff12, (err, res) => {
expect(err).not.to.be.ok();
expect(res).to.eql(fixtures.example_note.js);
done();
});
});
test('js2xliff', (fn) => (done) => {
fn(fixtures.example_note.js, (err, res) => {
expect(err).not.to.be.ok();
expect(res).to.eql(fixtures.example_note.xliff);
done();
});
});
test('targetOfjs', (fn) => (done) => {
fn(fixtures.example_note.js, (err, res) => {
expect(err).not.to.be.ok();
expect(res.namespace1['key.nested']).to.eql(fixtures.example_note.js.resources.namespace1['key.nested'].target);
expect(res.namespace2['k']).to.eql(fixtures.example_note.js.resources.namespace2['k'].target);
done();
});
});
test('sourceOfjs', (fn) => (done) => {
fn(fixtures.example_note.js, (err, res) => {
expect(err).not.to.be.ok();
expect(res.namespace1['key.nested']).to.eql(fixtures.example_note.js.resources.namespace1['key.nested'].source);
expect(res.namespace2['k']).to.eql(fixtures.example_note.js.resources.namespace2['k'].source);
done();
});
});
});

@@ -45,2 +45,5 @@ const xml2js = require('xml2js');

}
if (entry.note) {
result.resources[namespace][key].note = extractValue(entry.note[0]);
}
});

@@ -47,0 +50,0 @@ });

@@ -42,2 +42,6 @@ const xml2js = require('xml2js');

}
if (seg.note) {
const noteValue = seg.note[0];
result.resources[namespace][key].note = noteValue;
}
});

@@ -44,0 +48,0 @@ });

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