diff --git a/src/example.ts b/src/example.ts new file mode 100644 index 0000000..a87283b --- /dev/null +++ b/src/example.ts @@ -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()}`); +} diff --git a/src/test.ts b/src/test.ts deleted file mode 100644 index d977ef9..0000000 --- a/src/test.ts +++ /dev/null @@ -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; -}