Add support for marker functions, to be able to extract strings not directly passed to TranslateService. Closes #10

This commit is contained in:
Kim Biesbjerg
2017-03-30 14:37:30 +02:00
parent 42a6568d47
commit daaebede6f
11 changed files with 213 additions and 90 deletions

View File

@@ -0,0 +1,27 @@
import { expect } from 'chai';
import { FunctionParser } from '../../src/parsers/function.parser';
describe('FunctionParser', () => {
const componentFilename: string = 'test.component.ts';
let parser: FunctionParser;
beforeEach(() => {
parser = new FunctionParser();
});
it('should extract strings using marker function', () => {
const contents = `
import { _ } from '@biesbjerg/ngx-translate-extract';
_('Hello world');
_(['I', 'am', 'extracted']);
otherFunction('But I am not');
`;
const keys = parser.extract(contents, componentFilename).keys();
expect(keys).to.deep.equal(['Hello world', 'I', 'am', 'extracted']);
});
});