Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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:!`;