Comparing version 1.0.1 to 1.1.0
@@ -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 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30141
31
580