Renamed test.ts to example.ts and changed it to fit new interface

This commit is contained in:
Kim Biesbjerg 2016-12-04 22:57:52 +01:00
parent fbc92c3335
commit 6aeb0a69ad
2 changed files with 18 additions and 26 deletions

18
src/example.ts Normal file
View File

@ -0,0 +1,18 @@
import { Extractor } from './extractor';
import { JsonSerializer } from './serializers/json.serializer';
import { PotSerializer } from './serializers/pot.serializer';
const dir = '/path/to/extract/strings/from';
const dest = '/path/to/save/template/to/template.pot';
const serializer = new JsonSerializer();
// Or const serializer = new PotSerializer();
const extractor = new Extractor(serializer);
try {
const messages: string[] = extractor.extract(dir);
const output: string = extractor.save(dest);
console.log('Done!');
} catch (e) {
console.log(`Something went wrong: ${e.toString()}`);
}

View File

@ -1,26 +0,0 @@
import { Extractor } from './extractor';
import { JsonSerializer } from './serializers/json.serializer';
import { PotSerializer } from './serializers/pot.serializer';
const root = '/Users/kim/ionic/mindly-app/master/src';
const paths = [
root + '/**/*.html',
root + '/**/*.ts'
];
const destination = 'template.pot';
// const serializer = new JsonSerializer();
const serializer = new PotSerializer();
const extractor = new Extractor(serializer);
try {
extractor.extract(paths);
const output = extractor.save(destination);
console.log(`Extracted strings to "${destination}"`);
console.log();
console.log('OUTPUT:');
console.log(output);
} catch (e) {
console.log(`Error extracting strings to "${destination}"`);
throw e;
}