fix(localize): trim extracted `equiv-text` values (#41180)

The ViewEngine message extraction would trim the values
of the `equiv-text` attributes. This commit aligns the Ivy
extraction of these attributes.

Fixes #41176

PR Close #41180
This commit is contained in:
Pete Bacon Darwin 2021-03-11 15:43:05 +00:00 committed by Andrew Kushnir
parent 94e8f5d4a4
commit 69afeb3808
3 changed files with 8 additions and 3 deletions

View File

@ -123,7 +123,7 @@ export class MessageExtractor {
sourceFile.sources.find(sf => sf?.sourcePath === originalStart.file)!;
const startPos = originalSourceFile.startOfLinePositions[start.line] + start.column;
const endPos = originalSourceFile.startOfLinePositions[end.line] + end.column;
const text = originalSourceFile.contents.substring(startPos, endPos);
const text = originalSourceFile.contents.substring(startPos, endPos).trim();
return {file: originalStart.file, start, end, text};
}
}

View File

@ -399,7 +399,8 @@ runInNativeFileSystem(() => {
// These source file paths are due to how Bazel TypeScript compilation source-maps
// work
` <context context-type="sourcefile">../packages/localize/src/tools/test/extract/integration/test_files/src/a.ts</context>`,
` <context context-type="linenumber">3</context>`,
` <context context-type="linenumber">3,${
target === 'es2015' ? 7 : 5}</context>`,
` </context-group>`,
` </trans-unit>`,
` <trans-unit id="7829869508202074508" datatype="html">`,

View File

@ -1,3 +1,7 @@
declare const $localize: any;
const file = 'a.ts';
export const messageA = $localize`Message in ${file}:a-file:!`;
export const messageA = $localize`Message in ${
file
}:a-file:!`;