(feature) add StringAsDefaultValue. Closes #40

This commit is contained in:
Kim Biesbjerg
2020-03-07 09:21:01 +01:00
parent d579114dd2
commit 56a5ab31bf
3 changed files with 70 additions and 4 deletions

View File

@@ -0,0 +1,16 @@
import { TranslationCollection } from '../utils/translation.collection';
import { PostProcessorInterface } from './post-processor.interface';
interface Options {
defaultValue: string;
}
export class StringAsDefaultValuePostProcessor implements PostProcessorInterface {
public name: string = 'StringAsDefaultValue';
public constructor(protected options: Options) {}
public process(draft: TranslationCollection, extracted: TranslationCollection, existing: TranslationCollection): TranslationCollection {
return draft.map((key, val) => (existing.get(key) === undefined ? this.options.defaultValue : val));
}
}