From de783079285223eb9e29cfd4d19b7786cc201c9b Mon Sep 17 00:00:00 2001 From: Olivier Combe Date: Tue, 14 Nov 2017 10:22:19 +0100 Subject: [PATCH] fix(compiler-cli): normalize sourcepaths for i18n extracted files (#20417) Fixes #20416 PR Close #20417 --- packages/compiler-cli/src/transformers/program.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/compiler-cli/src/transformers/program.ts b/packages/compiler-cli/src/transformers/program.ts index 97e1ab0ae0..878dbb6d6f 100644 --- a/packages/compiler-cli/src/transformers/program.ts +++ b/packages/compiler-cli/src/transformers/program.ts @@ -803,9 +803,16 @@ export function i18nSerialize( default: serializer = new Xliff(); } - return bundle.write( - serializer, (sourcePath: string) => - options.basePath ? path.relative(options.basePath, sourcePath) : sourcePath); + + return bundle.write(serializer, getPathNormalizer(options.basePath)); +} + +function getPathNormalizer(basePath?: string) { + // normalize sourcepaths by removing the base path and always using "/" as a separator + return (sourcePath: string) => { + sourcePath = basePath ? path.relative(basePath, sourcePath) : sourcePath; + return sourcePath.split(path.sep).join('/'); + }; } export function i18nGetExtension(formatName: string): string {