Skip to content

Commit

Permalink
fix(localize): trim extracted equiv-text values (#41180)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
petebacondarwin authored and AndrewKushnir committed Mar 11, 2021
1 parent 78e6713 commit ed6c09a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/localize/src/tools/src/extract/extraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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">`,
Expand Down
Original file line number Diff line number Diff line change
@@ -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:!`;

0 comments on commit ed6c09a

Please sign in to comment.