Skip to content

Commit

Permalink
fix: to microsoft#157015 fix view label command localized (microsoft#…
Browse files Browse the repository at this point in the history
…193544)

* fix: to microsoft#157015 fix view label command localized

* chore: save

* Fixes microsoft#157015

* Fixes microsoft#157015

* Fixes microsoft#157015

* Fixes microsoft#157015

* Fixes microsoft#157015

* Fixes microsoft#157015

* fix: use nls.localize2 to simplified code

* fix: use nls.localize2 to simplified code

* fix: use nls.localize2 to simplified code

---------

Co-authored-by: Johannes Rieken <johannes.rieken@gmail.com>
Co-authored-by: Isidor Nikolic <inikolic@microsoft.com>
Co-authored-by: Megan Rogge <merogge@microsoft.com>
Co-authored-by: Ulugbek Abdullaev <ulugbekna@gmail.com>
  • Loading branch information
5 people authored and Alex0007 committed Oct 26, 2023
1 parent f472387 commit 139390c
Show file tree
Hide file tree
Showing 46 changed files with 301 additions and 290 deletions.
5 changes: 2 additions & 3 deletions src/vs/workbench/api/browser/mainThreadComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { extHostNamedCustomer, IExtHostContext } from 'vs/workbench/services/ext
import { ICommentController, ICommentInfo, ICommentService, INotebookCommentInfo } from 'vs/workbench/contrib/comments/browser/commentService';
import { CommentsPanel } from 'vs/workbench/contrib/comments/browser/commentsView';
import { CommentProviderFeatures, ExtHostCommentsShape, ExtHostContext, MainContext, MainThreadCommentsShape, CommentThreadChanges } from '../common/extHost.protocol';
import { COMMENTS_VIEW_ID, COMMENTS_VIEW_STORAGE_ID, COMMENTS_VIEW_TITLE, COMMENTS_VIEW_ORIGINAL_TITLE } from 'vs/workbench/contrib/comments/browser/commentsTreeViewer';
import { COMMENTS_VIEW_ID, COMMENTS_VIEW_STORAGE_ID, COMMENTS_VIEW_TITLE } from 'vs/workbench/contrib/comments/browser/commentsTreeViewer';
import { ViewContainer, IViewContainersRegistry, Extensions as ViewExtensions, ViewContainerLocation, IViewsRegistry, IViewsService, IViewDescriptorService } from 'vs/workbench/common/views';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ViewPaneContainer } from 'vs/workbench/browser/parts/views/viewPaneContainer';
Expand All @@ -26,7 +26,6 @@ import { MarshalledId } from 'vs/base/common/marshallingIds';
import { ICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
import { Schemas } from 'vs/base/common/network';


export class MainThreadCommentThread<T> implements languages.CommentThread<T> {
private _input?: languages.CommentInput;
get input(): languages.CommentInput | undefined {
Expand Down Expand Up @@ -601,7 +600,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
if (!commentsViewAlreadyRegistered) {
const VIEW_CONTAINER: ViewContainer = Registry.as<IViewContainersRegistry>(ViewExtensions.ViewContainersRegistry).registerViewContainer({
id: COMMENTS_VIEW_ID,
title: { value: COMMENTS_VIEW_TITLE, original: COMMENTS_VIEW_ORIGINAL_TITLE },
title: COMMENTS_VIEW_TITLE,
ctorDescriptor: new SyncDescriptor(ViewPaneContainer, [COMMENTS_VIEW_ID, { mergeViewWithContainerWhenSingleView: true }]),
storageId: COMMENTS_VIEW_STORAGE_ID,
hideIfEmpty: true,
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/browser/viewsExtensionPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
type: type,
ctorDescriptor: type === ViewType.Tree ? new SyncDescriptor(TreeViewPane) : new SyncDescriptor(WebviewViewPane),
id: item.id,
name: item.name,
name: { value: item.name, original: item.name },
when: ContextKeyExpr.deserialize(item.when),
containerIcon: icon || viewContainer?.icon,
containerTitle: item.contextualTitle || (viewContainer && (typeof viewContainer.title === 'string' ? viewContainer.title : viewContainer.title.value)),
Expand Down
5 changes: 3 additions & 2 deletions src/vs/workbench/api/test/browser/mainThreadTreeViews.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as nls from 'vs/nls';
import * as assert from 'assert';
import { mock } from 'vs/base/test/common/mock';
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
Expand Down Expand Up @@ -56,11 +57,11 @@ suite('MainThreadHostTreeView', function () {
const instantiationService: TestInstantiationService = <TestInstantiationService>workbenchInstantiationService(undefined, disposables);
const viewDescriptorService = disposables.add(instantiationService.createInstance(ViewDescriptorService));
instantiationService.stub(IViewDescriptorService, viewDescriptorService);
container = Registry.as<IViewContainersRegistry>(Extensions.ViewContainersRegistry).registerViewContainer({ id: 'testContainer', title: { value: 'test', original: 'test' }, ctorDescriptor: new SyncDescriptor(<any>{}) }, ViewContainerLocation.Sidebar);
container = Registry.as<IViewContainersRegistry>(Extensions.ViewContainersRegistry).registerViewContainer({ id: 'testContainer', title: nls.localize2('test', 'test'), ctorDescriptor: new SyncDescriptor(<any>{}) }, ViewContainerLocation.Sidebar);
const viewDescriptor: ITreeViewDescriptor = {
id: testTreeViewId,
ctorDescriptor: null!,
name: 'Test View 1',
name: nls.localize2('Test View 1', 'Test View 1'),
treeView: disposables.add(instantiationService.createInstance(CustomTreeView, 'testTree', 'Test Title', 'extension.id')),
};
ViewsRegistry.registerViews([viewDescriptor], container);
Expand Down
8 changes: 4 additions & 4 deletions src/vs/workbench/browser/actions/layoutActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ registerAction2(class extends Action2 {

results.push({
id: viewDescriptor.id,
label: viewDescriptor.name
label: viewDescriptor.name.value
});
}
});
Expand All @@ -728,7 +728,7 @@ registerAction2(class extends Action2 {

results.push({
id: viewDescriptor.id,
label: viewDescriptor.name
label: viewDescriptor.name.value
});
}
});
Expand All @@ -753,7 +753,7 @@ registerAction2(class extends Action2 {

results.push({
id: viewDescriptor.id,
label: viewDescriptor.name
label: viewDescriptor.name.value
});
}
});
Expand Down Expand Up @@ -827,7 +827,7 @@ class MoveFocusedViewAction extends Action2 {

const quickPick = quickInputService.createQuickPick();
quickPick.placeholder = localize('moveFocusedView.selectDestination', "Select a Destination for the View");
quickPick.title = localize({ key: 'moveFocusedView.title', comment: ['{0} indicates the title of the view the user has selected to move.'] }, "View: Move {0}", viewDescriptor.name);
quickPick.title = localize({ key: 'moveFocusedView.title', comment: ['{0} indicates the title of the view the user has selected to move.'] }, "View: Move {0}", viewDescriptor.name.value);

const items: Array<IQuickPickItem | IQuickPickSeparator> = [];
const currentContainer = viewDescriptorService.getViewContainerByViewId(focusedViewId)!;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/parts/views/viewPaneContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
const pane = this.createView(viewDescriptor,
{
id: viewDescriptor.id,
title: viewDescriptor.name,
title: viewDescriptor.name.value,
fromExtensionId: (viewDescriptor as Partial<ICustomViewDescriptor>).extensionId,
expanded: !collapsed
});
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/browser/parts/views/viewsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class ViewsService extends Disposable implements IViewsService {

getFocusedViewName(): string {
const viewId: string = this.contextKeyService.getContextKeyValue(FocusedViewContext.key) ?? '';
return this.viewDescriptorService.getViewDescriptorById(viewId.toString())?.name ?? '';
return this.viewDescriptorService.getViewDescriptorById(viewId.toString())?.name?.value ?? '';
}

async openView<T extends IView>(id: string, focus?: boolean): Promise<T | null> {
Expand Down Expand Up @@ -484,10 +484,10 @@ export class ViewsService extends Disposable implements IViewsService {
private registerFocusViewAction(viewDescriptor: IViewDescriptor, category?: string | ILocalizedString): IDisposable {
return registerAction2(class FocusViewAction extends Action2 {
constructor() {
const title = localize({ key: 'focus view', comment: ['{0} indicates the name of the view to be focused.'] }, "Focus on {0} View", viewDescriptor.name);
const title = localize({ key: 'focus view', comment: ['{0} indicates the name of the view to be focused.'] }, "Focus on {0} View", viewDescriptor.name.value);
super({
id: viewDescriptor.focusCommand ? viewDescriptor.focusCommand.id : `${viewDescriptor.id}.focus`,
title: { original: `Focus on ${viewDescriptor.name} View`, value: title },
title: { original: `Focus on ${viewDescriptor.name.original} View`, value: title },
category,
menu: [{
id: MenuId.CommandPalette,
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/common/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export interface IViewDescriptor {

readonly id: string;

readonly name: string;
readonly name: ILocalizedString;

readonly ctorDescriptor: SyncDescriptor<IView>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { IBulkEditService, ResourceEdit } from 'vs/editor/browser/services/bulkE
import { BulkEditPane } from 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPane';
import { IViewContainersRegistry, Extensions as ViewContainerExtensions, ViewContainerLocation, IViewsRegistry, IViewsService } from 'vs/workbench/common/views';
import { FocusedViewContext } from 'vs/workbench/common/contextkeys';
import { localize } from 'vs/nls';
import { localize, localize2 } from 'vs/nls';
import { ViewPaneContainer } from 'vs/workbench/browser/parts/views/viewPaneContainer';
import { RawContextKey, IContextKeyService, IContextKey, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
Expand Down Expand Up @@ -166,8 +166,8 @@ registerAction2(class ApplyAction extends Action2 {
constructor() {
super({
id: 'refactorPreview.apply',
title: { value: localize('apply', "Apply Refactoring"), original: 'Apply Refactoring' },
category: { value: localize('cat', "Refactor Preview"), original: 'Refactor Preview' },
title: localize2('apply', "Apply Refactoring"),
category: localize2('cat', "Refactor Preview"),
icon: Codicon.check,
precondition: ContextKeyExpr.and(BulkEditPreviewContribution.ctxEnabled, BulkEditPane.ctxHasCheckedChanges),
menu: [{
Expand Down Expand Up @@ -195,8 +195,8 @@ registerAction2(class DiscardAction extends Action2 {
constructor() {
super({
id: 'refactorPreview.discard',
title: { value: localize('Discard', "Discard Refactoring"), original: 'Discard Refactoring' },
category: { value: localize('cat', "Refactor Preview"), original: 'Refactor Preview' },
title: localize2('Discard', "Discard Refactoring"),
category: localize2('cat', "Refactor Preview"),
icon: Codicon.clearAll,
precondition: BulkEditPreviewContribution.ctxEnabled,
menu: [{
Expand All @@ -220,8 +220,8 @@ registerAction2(class ToggleAction extends Action2 {
constructor() {
super({
id: 'refactorPreview.toggleCheckedState',
title: { value: localize('toogleSelection', "Toggle Change"), original: 'Toggle Change' },
category: { value: localize('cat', "Refactor Preview"), original: 'Refactor Preview' },
title: localize2('toogleSelection', "Toggle Change"),
category: localize2('cat', "Refactor Preview"),
precondition: BulkEditPreviewContribution.ctxEnabled,
keybinding: {
weight: KeybindingWeight.WorkbenchContrib,
Expand Down Expand Up @@ -249,8 +249,8 @@ registerAction2(class GroupByFile extends Action2 {
constructor() {
super({
id: 'refactorPreview.groupByFile',
title: { value: localize('groupByFile', "Group Changes By File"), original: 'Group Changes By File' },
category: { value: localize('cat', "Refactor Preview"), original: 'Refactor Preview' },
title: localize2('groupByFile', "Group Changes By File"),
category: localize2('cat', "Refactor Preview"),
icon: Codicon.ungroupByRefType,
precondition: ContextKeyExpr.and(BulkEditPane.ctxHasCategories, BulkEditPane.ctxGroupByFile.negate(), BulkEditPreviewContribution.ctxEnabled),
menu: [{
Expand All @@ -274,8 +274,8 @@ registerAction2(class GroupByType extends Action2 {
constructor() {
super({
id: 'refactorPreview.groupByType',
title: { value: localize('groupByType', "Group Changes By Type"), original: 'Group Changes By Type' },
category: { value: localize('cat', "Refactor Preview"), original: 'Refactor Preview' },
title: localize2('groupByType', "Group Changes By Type"),
category: localize2('cat', "Refactor Preview"),
icon: Codicon.groupByRefType,
precondition: ContextKeyExpr.and(BulkEditPane.ctxHasCategories, BulkEditPane.ctxGroupByFile, BulkEditPreviewContribution.ctxEnabled),
menu: [{
Expand All @@ -299,8 +299,8 @@ registerAction2(class ToggleGrouping extends Action2 {
constructor() {
super({
id: 'refactorPreview.toggleGrouping',
title: { value: localize('groupByType', "Group Changes By Type"), original: 'Group Changes By Type' },
category: { value: localize('cat', "Refactor Preview"), original: 'Refactor Preview' },
title: localize2('groupByType', "Group Changes By Type"),
category: localize2('cat', "Refactor Preview"),
icon: Codicon.listTree,
toggled: BulkEditPane.ctxGroupByFile.negate(),
precondition: ContextKeyExpr.and(BulkEditPane.ctxHasCategories, BulkEditPreviewContribution.ctxEnabled),
Expand All @@ -326,7 +326,7 @@ const refactorPreviewViewIcon = registerIcon('refactor-preview-view-icon', Codic

const container = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer({
id: BulkEditPane.ID,
title: { value: localize('panel', "Refactor Preview"), original: 'Refactor Preview' },
title: localize2('panel', "Refactor Preview"),
hideIfEmpty: true,
ctorDescriptor: new SyncDescriptor(
ViewPaneContainer,
Expand All @@ -338,7 +338,7 @@ const container = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.V

Registry.as<IViewsRegistry>(ViewContainerExtensions.ViewsRegistry).registerViews([{
id: BulkEditPane.ID,
name: localize('panel', "Refactor Preview"),
name: localize2('panel', "Refactor Preview"),
when: BulkEditPreviewContribution.ctxEnabled,
ctorDescriptor: new SyncDescriptor(BulkEditPane),
containerIcon: refactorPreviewViewIcon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { Codicon } from 'vs/base/common/codicons';
import { DisposableStore, IDisposable } from 'vs/base/common/lifecycle';
import * as resources from 'vs/base/common/resources';
import { localize } from 'vs/nls';
import { localize, localize2 } from 'vs/nls';
import { registerAction2 } from 'vs/platform/actions/common/actions';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
Expand Down Expand Up @@ -106,12 +106,12 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution {

private registerViewContainer(): ViewContainer {
// Register View Container
const title = localize('chat.viewContainer.label', "Chat");
const title = localize2('chat.viewContainer.label', "Chat");
const icon = Codicon.commentDiscussion;
const viewContainerId = CHAT_SIDEBAR_PANEL_ID;
const viewContainer: ViewContainer = Registry.as<IViewContainersRegistry>(ViewExtensions.ViewContainersRegistry).registerViewContainer({
id: viewContainerId,
title: { value: title, original: 'Chat' },
title,
icon,
ctorDescriptor: new SyncDescriptor(ViewPaneContainer, [viewContainerId, { mergeViewWithContainerWhenSingleView: true }]),
storageId: viewContainerId,
Expand All @@ -129,7 +129,7 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution {
id: viewId,
containerIcon: this._viewContainer.icon,
containerTitle: this._viewContainer.title.value,
name: providerDescriptor.label,
name: { value: providerDescriptor.label, original: providerDescriptor.label },
canToggleVisibility: false,
canMoveView: true,
ctorDescriptor: new SyncDescriptor(ChatViewPane, [<IChatViewOptions>{ providerId: providerDescriptor.id }]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import { basename } from 'vs/base/common/resources';
import { openLinkFromMarkdown } from 'vs/editor/contrib/markdownRenderer/browser/markdownRenderer';
import { IStyleOverride } from 'vs/platform/theme/browser/defaultStyles';
import { IListStyles } from 'vs/base/browser/ui/list/listWidget';
import { ILocalizedString } from 'vs/platform/action/common/action';

export const COMMENTS_VIEW_ID = 'workbench.panel.comments';
export const COMMENTS_VIEW_STORAGE_ID = 'Comments';
export const COMMENTS_VIEW_ORIGINAL_TITLE = 'Comments';
export const COMMENTS_VIEW_TITLE = nls.localize('comments.view.title', "Comments");
export const COMMENTS_VIEW_TITLE: ILocalizedString = nls.localize2('comments.view.title', "Comments");

interface IResourceTemplateData {
resourceLabel: IResourceLabel;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/comments/browser/commentsView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ export class CommentsPanel extends FilterViewPane implements ICommentsView {
return '';
},
getWidgetAriaLabel(): string {
return COMMENTS_VIEW_TITLE;
return COMMENTS_VIEW_TITLE.value;
}
}
}));
Expand Down
Loading

0 comments on commit 139390c

Please sign in to comment.