From ce1efc1af22721b26f43454a18e0bfb8f2a89e6a Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Thu, 10 Sep 2020 09:17:42 +0100 Subject: [PATCH] fix(localize): ensure that `formatOptions` is optional (#38787) Some lower level APIs are used by CLI, and requiring the `formatOpions` argument at that level is a breaking change. This commit makes it optional at every level to avoid the breaking change. PR Close #38787 --- packages/localize/src/tools/src/extract/main.ts | 2 +- .../extract/translation_files/xliff1_translation_serializer.ts | 2 +- .../extract/translation_files/xliff2_translation_serializer.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/localize/src/tools/src/extract/main.ts b/packages/localize/src/tools/src/extract/main.ts index 27d50f6212..646fab708e 100644 --- a/packages/localize/src/tools/src/extract/main.ts +++ b/packages/localize/src/tools/src/extract/main.ts @@ -208,7 +208,7 @@ export function extractTranslations({ export function getSerializer( format: string, sourceLocale: string, rootPath: AbsoluteFsPath, useLegacyIds: boolean, - formatOptions: FormatOptions): TranslationSerializer { + formatOptions: FormatOptions = {}): TranslationSerializer { switch (format) { case 'xlf': case 'xlif': diff --git a/packages/localize/src/tools/src/extract/translation_files/xliff1_translation_serializer.ts b/packages/localize/src/tools/src/extract/translation_files/xliff1_translation_serializer.ts index f56a4addf2..6ff7643f13 100644 --- a/packages/localize/src/tools/src/extract/translation_files/xliff1_translation_serializer.ts +++ b/packages/localize/src/tools/src/extract/translation_files/xliff1_translation_serializer.ts @@ -27,7 +27,7 @@ const LEGACY_XLIFF_MESSAGE_LENGTH = 40; export class Xliff1TranslationSerializer implements TranslationSerializer { constructor( private sourceLocale: string, private basePath: AbsoluteFsPath, private useLegacyIds: boolean, - private formatOptions: FormatOptions) { + private formatOptions: FormatOptions = {}) { validateOptions('Xliff1TranslationSerializer', [['xml:space', ['preserve']]], formatOptions); } diff --git a/packages/localize/src/tools/src/extract/translation_files/xliff2_translation_serializer.ts b/packages/localize/src/tools/src/extract/translation_files/xliff2_translation_serializer.ts index 395e4c1bbe..d01fd63662 100644 --- a/packages/localize/src/tools/src/extract/translation_files/xliff2_translation_serializer.ts +++ b/packages/localize/src/tools/src/extract/translation_files/xliff2_translation_serializer.ts @@ -27,7 +27,7 @@ export class Xliff2TranslationSerializer implements TranslationSerializer { private currentPlaceholderId = 0; constructor( private sourceLocale: string, private basePath: AbsoluteFsPath, private useLegacyIds: boolean, - private formatOptions: FormatOptions) { + private formatOptions: FormatOptions = {}) { validateOptions('Xliff1TranslationSerializer', [['xml:space', ['preserve']]], formatOptions); }