Renamed test.ts to example.ts and changed it to fit new interface
This commit is contained in:
		
							
								
								
									
										18
									
								
								src/example.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/example.ts
									
									
									
									
									
										Normal 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()}`); | ||||
| } | ||||
							
								
								
									
										26
									
								
								src/test.ts
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								src/test.ts
									
									
									
									
									
								
							| @@ -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; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user