Skip to content

Commit e8ce9b3

Browse files
authored
SCM - fix statistics tooltip localization (#197896)
1 parent df2dd86 commit e8ce9b3

File tree

1 file changed

+25
-33
lines changed

1 file changed

+25
-33
lines changed

src/vs/workbench/contrib/scm/browser/scmViewPane.ts

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -733,12 +733,9 @@ class HistoryItemGroupRenderer implements ICompressibleTreeRenderer<SCMHistoryIt
733733

734734
interface HistoryItemTemplate {
735735
readonly iconContainer: HTMLElement;
736-
// readonly avatarImg: HTMLImageElement;
737-
readonly iconLabel: IconLabel;
736+
readonly label: IconLabel;
738737
readonly statsContainer: HTMLElement;
739738
readonly statsLabel: IconLabel;
740-
// readonly timestampContainer: HTMLElement;
741-
// readonly timestamp: HTMLSpanElement;
742739
readonly disposables: IDisposable;
743740
}
744741

@@ -759,12 +756,7 @@ class HistoryItemRenderer implements ICompressibleTreeRenderer<SCMHistoryItemTre
759756
const statsContainer = append(element, $('.stats-container'));
760757
const statsLabel = new IconLabel(statsContainer, { supportIcons: true });
761758

762-
// const avatarImg = append(iconContainer, $('img.avatar')) as HTMLImageElement;
763-
764-
// const timestampContainer = append(iconLabel.element, $('.timestamp-container'));
765-
// const timestamp = append(timestampContainer, $('span.timestamp'));
766-
767-
return { iconContainer, iconLabel, statsContainer, statsLabel, disposables: new DisposableStore() };
759+
return { iconContainer, label: iconLabel, statsContainer, statsLabel, disposables: new DisposableStore() };
768760
}
769761

770762
renderElement(node: ITreeNode<SCMHistoryItemTreeElement, void>, index: number, templateData: HistoryItemTemplate, height: number | undefined): void {
@@ -775,47 +767,47 @@ class HistoryItemRenderer implements ICompressibleTreeRenderer<SCMHistoryItemTre
775767
templateData.iconContainer.classList.add(...ThemeIcon.asClassNameArray(historyItem.icon));
776768
}
777769

778-
// if (commit.authorAvatar) {
779-
// templateData.avatarImg.src = commit.authorAvatar;
780-
// templateData.avatarImg.style.display = 'block';
781-
// templateData.iconContainer.classList.remove(...ThemeIcon.asClassNameArray(Codicon.account));
782-
// } else {
783-
// templateData.avatarImg.style.display = 'none';
784-
// templateData.iconContainer.classList.add(...ThemeIcon.asClassNameArray(Codicon.account));
785-
// }
770+
templateData.label.setLabel(historyItem.label, historyItem.description);
771+
this.renderStatistics(node, index, templateData, height);
772+
}
773+
774+
renderCompressedElements(node: ITreeNode<ICompressedTreeNode<SCMHistoryItemTreeElement>, void>, index: number, templateData: HistoryItemTemplate, height: number | undefined): void {
775+
throw new Error('Should never happen since node is incompressible');
776+
}
786777

787-
templateData.iconLabel.setLabel(historyItem.label, historyItem.description);
778+
private renderStatistics(node: ITreeNode<SCMHistoryItemTreeElement, void>, index: number, templateData: HistoryItemTemplate, height: number | undefined): void {
779+
const historyItem = node.element;
788780

789781
if (historyItem.statistics?.files || historyItem.statistics?.insertions || historyItem.statistics?.deletions) {
790782
const statsLabelTitle: string[] = [];
783+
791784
const filesLabel = historyItem.statistics?.files ? `${historyItem.statistics.files}$(files)` : '';
792-
if (filesLabel !== '') {
793-
statsLabelTitle.push(`${historyItem.statistics.files} ${historyItem.statistics.files === 1 ? 'file' : 'files'} changed`);
785+
const insertionsLabel = historyItem.statistics?.insertions ? ` ${historyItem.statistics.insertions}$(diff-added)` : '';
786+
const deletionsLabel = historyItem.statistics?.deletions ? ` ${historyItem.statistics.deletions}$(diff-removed)` : '';
787+
788+
if (historyItem.statistics?.files) {
789+
const filesDescription = historyItem.statistics.files === 1 ?
790+
localize('fileChanged', "file changed") : localize('filesChanged', "files changed");
791+
statsLabelTitle.push(`${historyItem.statistics.files} ${filesDescription}`);
794792
}
795793

796-
const insertionsLabel = historyItem.statistics?.insertions ? ` ${historyItem.statistics.insertions}$(diff-added)` : '';
797-
if (insertionsLabel !== '') {
798-
statsLabelTitle.push(`${historyItem.statistics.insertions} insertions(+)`);
794+
if (historyItem.statistics?.insertions) {
795+
const insertionsDescription = localize('insertions', "insertions{0}", '(+)');
796+
statsLabelTitle.push(`${historyItem.statistics.insertions} ${insertionsDescription}`);
799797
}
800798

801-
const deletionsLabel = historyItem.statistics?.deletions ? ` ${historyItem.statistics.deletions}$(diff-removed)` : '';
802-
if (deletionsLabel !== '') {
803-
statsLabelTitle.push(`${historyItem.statistics.deletions} deletions(-)`);
799+
if (historyItem.statistics?.deletions) {
800+
const deletionsDescription = localize('deletions', "deletions{0}", '(-)');
801+
statsLabelTitle.push(`${historyItem.statistics.deletions} ${deletionsDescription}`);
804802
}
805803

806804
templateData.statsLabel.setLabel(`${filesLabel}${insertionsLabel}${deletionsLabel}`, undefined, { title: statsLabelTitle.join(', ') });
807805
templateData.statsContainer.style.display = '';
808806
} else {
809807
templateData.statsContainer.style.display = 'none';
810808
}
811-
812-
// templateData.timestampContainer.classList.toggle('timestamp-duplicate', commit.hideTimestamp === true);
813-
// templateData.timestamp.textContent = fromNow(commit.timestamp);
814809
}
815810

816-
renderCompressedElements(node: ITreeNode<ICompressedTreeNode<SCMHistoryItemTreeElement>, void>, index: number, templateData: HistoryItemTemplate, height: number | undefined): void {
817-
throw new Error('Should never happen since node is incompressible');
818-
}
819811
disposeTemplate(templateData: HistoryItemTemplate): void {
820812
templateData.disposables.dispose();
821813
}

0 commit comments

Comments
 (0)