@biesbjerg/ng2-translate-extract
Advanced tools
Comparing version
@@ -5,3 +5,2 @@ "use strict"; | ||
const serializer = new json_serializer_1.JsonSerializer(); | ||
// Or const serializer = new PotSerializer(); | ||
const extractor = new extractor_1.Extractor(serializer); | ||
@@ -8,0 +7,0 @@ const src = '/your/project'; |
@@ -9,22 +9,7 @@ import { ParserInterface } from './parsers/parser.interface'; | ||
constructor(serializer: SerializerInterface); | ||
/** | ||
* Extracts messages from paths | ||
*/ | ||
extract(dir: string): string[]; | ||
/** | ||
* Serialize and return output | ||
*/ | ||
serialize(): string; | ||
/** | ||
* Serialize and save to destination | ||
*/ | ||
save(destination: string): string; | ||
/** | ||
* Get all files in dir that matches glob patterns | ||
*/ | ||
protected _getFiles(dir: string): string[]; | ||
/** | ||
* Extract messages from file using parser | ||
*/ | ||
protected _extractMessages(filePath: string): string[]; | ||
} |
@@ -23,5 +23,2 @@ "use strict"; | ||
} | ||
/** | ||
* Extracts messages from paths | ||
*/ | ||
extract(dir) { | ||
@@ -35,11 +32,5 @@ let messages = []; | ||
} | ||
/** | ||
* Serialize and return output | ||
*/ | ||
serialize() { | ||
return this.serializer.serialize(this.messages); | ||
} | ||
/** | ||
* Serialize and save to destination | ||
*/ | ||
save(destination) { | ||
@@ -50,5 +41,2 @@ const data = this.serialize(); | ||
} | ||
/** | ||
* Get all files in dir that matches glob patterns | ||
*/ | ||
_getFiles(dir) { | ||
@@ -64,5 +52,2 @@ let results = []; | ||
} | ||
/** | ||
* Extract messages from file using parser | ||
*/ | ||
_extractMessages(filePath) { | ||
@@ -69,0 +54,0 @@ let results = []; |
export declare abstract class AbstractTemplateParser { | ||
/** | ||
* Checks if file is of type javascript or typescript and | ||
* makes the assumption that it is an Angular Component | ||
*/ | ||
protected _isAngularComponent(filePath: string): boolean; | ||
/** | ||
* Extracts inline template from components | ||
*/ | ||
protected _extractInlineTemplate(contents: string): string; | ||
/** | ||
* Angular's `[attr]="'val'"` syntax is not valid HTML, | ||
* so it can't be parsed by standard HTML parsers. | ||
* This method replaces `[attr]="'val'""` with `attr="val"` | ||
*/ | ||
protected _normalizeTemplateAttributes(template: string): string; | ||
} |
"use strict"; | ||
class AbstractTemplateParser { | ||
/** | ||
* Checks if file is of type javascript or typescript and | ||
* makes the assumption that it is an Angular Component | ||
*/ | ||
_isAngularComponent(filePath) { | ||
return new RegExp(/\.(ts|js)$/, 'i').test(filePath); | ||
} | ||
/** | ||
* Extracts inline template from components | ||
*/ | ||
_extractInlineTemplate(contents) { | ||
@@ -20,7 +13,2 @@ const match = new RegExp(/template\s?:\s?("|\'|`)((.|[\r\n])+?[^\\])\1/).exec(contents); | ||
} | ||
/** | ||
* Angular's `[attr]="'val'"` syntax is not valid HTML, | ||
* so it can't be parsed by standard HTML parsers. | ||
* This method replaces `[attr]="'val'""` with `attr="val"` | ||
*/ | ||
_normalizeTemplateAttributes(template) { | ||
@@ -27,0 +15,0 @@ return template.replace(/\[([^\]]+)\]="'([^']*)'"/g, '$1="$2"'); |
@@ -19,3 +19,3 @@ "use strict"; | ||
const $element = $(element); | ||
const attr = $element.attr('translate'); | ||
const attr = $element.attr('translate') || $element.attr('ng2-translate'); | ||
if (attr) { | ||
@@ -22,0 +22,0 @@ results.push(attr); |
import { ParserInterface } from './parser.interface'; | ||
export declare class ServiceParser implements ParserInterface { | ||
process(filePath: string, contents: string): string[]; | ||
/** | ||
* Checks if string contains an array | ||
*/ | ||
protected _stringContainsArray(input: string): boolean; | ||
/** | ||
* Converts string to array | ||
*/ | ||
protected _stringToArray(input: string): string[]; | ||
/** | ||
* Extracts name of TranslateService variable for use in patterns | ||
*/ | ||
protected _extractTranslateServiceVar(contents: string): string; | ||
} |
@@ -22,11 +22,5 @@ "use strict"; | ||
} | ||
/** | ||
* Checks if string contains an array | ||
*/ | ||
_stringContainsArray(input) { | ||
return input.startsWith('[') && input.endsWith(']'); | ||
} | ||
/** | ||
* Converts string to array | ||
*/ | ||
_stringToArray(input) { | ||
@@ -38,5 +32,2 @@ if (this._stringContainsArray(input)) { | ||
} | ||
/** | ||
* Extracts name of TranslateService variable for use in patterns | ||
*/ | ||
_extractTranslateServiceVar(contents) { | ||
@@ -43,0 +34,0 @@ const matches = contents.match(/([a-z0-9_]+)\s*:\s*TranslateService/i); |
{ | ||
"name": "@biesbjerg/ng2-translate-extract", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Extract strings from projects using ng2-translate", | ||
@@ -28,2 +28,3 @@ "main": "dist/index.js", | ||
"ionic", | ||
"ionic2", | ||
"ng2-translate", | ||
@@ -30,0 +31,0 @@ "extract", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
23351
-8.15%33
-2.94%338
-19.33%