Skip to content
This repository has been archived by the owner on Feb 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #58 from kellyselden/revert-57-master
Browse files Browse the repository at this point in the history
Revert "added dotted key export notation to to-js."
  • Loading branch information
kellyselden committed Jun 24, 2016
2 parents 2d33372 + 2048871 commit 3a1eeae
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 69 deletions.
7 changes: 1 addition & 6 deletions bin/ember-i18n-csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ var argv = require('yargs')
},
'merge': {
type: 'boolean'
},
'dotted':{
type: 'boolean'
}
})
.argv;
Expand All @@ -27,13 +24,11 @@ var csvPath = argv['csv-path'];
var ignoreJshint = argv['jshint-ignore'];
var onlyMissing = argv['only-missing'];
var merge = argv['merge'];
var dotted = argv['dotted'];

var options = {
ignoreJshint: ignoreJshint,
onlyMissing: onlyMissing,
merge: merge,
dotted:dotted
merge: merge
};

emberI18nCsv(direction, localesPath, csvPath, options);
20 changes: 8 additions & 12 deletions lib/to-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const readFile = denodeify(fs.readFile);
const writeFile = denodeify(fs.writeFile);
const parse = denodeify(csvParse);

export default function(csvPath, localesPath, { ignoreJshint, merge, dotted } = {}) {
export default function(csvPath, localesPath, { ignoreJshint, merge } = {}) {
return readFile(csvPath, 'utf8').then(csv => {
return parse(csv);
}).then(lines => {
Expand All @@ -30,18 +30,14 @@ export default function(csvPath, localesPath, { ignoreJshint, merge, dotted } =
}

function recurse(keySections, obj, value) {
if(dotted){
obj[keySections.join('.')] = value;
}else{
let key = keySections[0];
if (keySections.length > 1) {
if (!obj[key]) {
obj[key] = {};
}
recurse(keySections.slice(1), obj[key], value);
} else {
obj[key] = value;
let key = keySections[0];
if (keySections.length > 1) {
if (!obj[key]) {
obj[key] = {};
}
recurse(keySections.slice(1), obj[key], value);
} else {
obj[key] = value;
}
}

Expand Down
24 changes: 0 additions & 24 deletions test/acceptance/to-js-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,4 @@ describe('acceptance - to-js', function() {
}).catch(done);
});
});

it('handles option --dotted', function(done) {
let ps = spawn(process.execPath, [
'bin/ember-i18n-csv.js',
'to-js',
'--csv-path=test/fixtures/i18n-dotted.csv',
'--locales-path=tmp/locales',
'--dotted'
]);

let out = '';
let err = '';
ps.stdout.on('data', buffer => out += buffer);
ps.stderr.on('data', buffer => err += buffer);

ps.on('exit', () => {
expect(out).to.equal('');
expect(err).to.equal('');
areDirsEqual('tmp/locales', 'test/fixtures/locales-dotted').then(areSame => {
expect(areSame).to.be.true;
done();
}).catch(done);
});
});
});
5 changes: 0 additions & 5 deletions test/fixtures/i18n-dotted.csv

This file was deleted.

4 changes: 0 additions & 4 deletions test/fixtures/locales-dotted/en-us/translations.js

This file was deleted.

4 changes: 0 additions & 4 deletions test/fixtures/locales-dotted/nl-nl/translations.js

This file was deleted.

5 changes: 0 additions & 5 deletions test/fixtures/locales-dotted/pt-br/translations.js

This file was deleted.

9 changes: 0 additions & 9 deletions test/integration/ember-i18n-csv-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ describe('integration - ember-i18n-csv', function() {
});
});
});

describe('merge', function() {
beforeEach(function() {
fs.copySync('test/fixtures/locales-with-missing-keys', 'tmp/locales', { clobber: true });
Expand All @@ -81,14 +80,6 @@ describe('integration - ember-i18n-csv', function() {
});
});
});

it('handles option --dotted', function() {
return emberI18nCsv('to-js', 'tmp/locales', 'test/fixtures/i18n-dotted.csv', { dotted: true }).then(() => {
return areDirsEqual('tmp/locales', 'test/fixtures/locales-dotted').then(areSame => {
expect(areSame).to.be.true;
});
});
});
});
});

Expand Down

0 comments on commit 3a1eeae

Please sign in to comment.