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

Refactor format of l10n strings to standard format #3137

Closed
wants to merge 8 commits into from
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/zowe-explorer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t

- Updated the `TableViewProvider.setTableView` function to show the Zowe Resources panel if a table is provided. If `null` is passed, the Zowe Resources panel will be hidden. [#3113](https://github.com/zowe/zowe-explorer-vscode/issues/3113)
- Fixed behavior of logout action when token is defined in both base profile and parent profile. [#3076](https://github.com/zowe/zowe-explorer-vscode/issues/3076)
- Fixed issue with object based parameter being passed to VS Code's localization API.

## `3.0.0-next.202409132122`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe("diffOverwrite", () => {
fsEntry.data
);
blockMocks.writeFileMock.mockClear();
expect(statusBarMsgMock.mock.calls[0][0]).toBe("$(check) Overwrite applied for file.txt");
expect(statusBarMsgMock.mock.calls[0][0]).toBe("$(check) Overwrite applied for {0}");
expect(fsEntry.conflictData).toBeNull();
});

Expand Down Expand Up @@ -121,7 +121,7 @@ describe("diffUseRemote", () => {
conflictArr
);
blockMocks.writeFileMock.mockClear();
expect(statusBarMsgMock.mock.calls[0][0]).toBe("$(check) Overwrite applied for file.txt");
expect(statusBarMsgMock.mock.calls[0][0]).toBe("$(check) Overwrite applied for {0}");
expect(fsEntry.conflictData).toBeNull();
expect(executeCommandMock).toHaveBeenCalledWith("workbench.action.closeActiveEditor");
});
Expand All @@ -145,7 +145,7 @@ describe("diffUseRemote", () => {

expect(blockMocks.lookupAsFileMock).toHaveBeenCalled();
expect(blockMocks.writeFileMock).not.toHaveBeenCalled();
expect(statusBarMsgMock.mock.calls[0][0]).toBe("$(check) Overwrite applied for file.txt");
expect(statusBarMsgMock.mock.calls[0][0]).toBe("$(check) Overwrite applied for {0}");
expect(fsEntry.conflictData).toBeNull();
expect(executeCommandMock).toHaveBeenCalledWith("workbench.action.closeActiveEditor");
});
Expand Down
18 changes: 2 additions & 16 deletions packages/zowe-explorer-api/src/fs/BaseProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,7 @@ export class BaseProvider {
return;
}
await vscode.workspace.fs.writeFile(uri.with({ query: "forceUpload=true" }), fsEntry.data);
Gui.setStatusBarMessage(
vscode.l10n.t({
message: "$(check) Overwrite applied for {0}",
args: [fsEntry.name],
comment: "File name",
}),
this.FS_PROVIDER_UI_TIMEOUT
);
Gui.setStatusBarMessage(vscode.l10n.t("$(check) Overwrite applied for {0}", [fsEntry.name]), this.FS_PROVIDER_UI_TIMEOUT);
fsEntry.conflictData = null;
vscode.commands.executeCommand("workbench.action.closeActiveEditor");
}
Expand All @@ -79,14 +72,7 @@ export class BaseProvider {
if (!isDataEqual) {
await vscode.workspace.fs.writeFile(uri.with({ query: "forceUpload=true" }), fsEntry.conflictData.contents);
}
Gui.setStatusBarMessage(
vscode.l10n.t({
message: "$(discard) Used remote content for {0}",
args: [fsEntry.name],
comment: "File name",
}),
this.FS_PROVIDER_UI_TIMEOUT
);
Gui.setStatusBarMessage(vscode.l10n.t("$(discard) Used remote content for {0}", [fsEntry.name]), this.FS_PROVIDER_UI_TIMEOUT);
fsEntry.conflictData = null;
vscode.commands.executeCommand("workbench.action.closeActiveEditor");
}
Expand Down
1 change: 1 addition & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
- Fix issue with extender profiles not being included in fresh team configuration file. [#3122](https://github.com/zowe/zowe-explorer-vscode/issues/3122)
- Fixed issue where file extensions were removed from data sets, causing language detection to sometimes fail for Zowe Explorer extenders. [#3121](https://github.com/zowe/zowe-explorer-vscode/issues/3121)
- Fixed an issue where copying and pasting a file/folder in the USS tree would fail abruptly, displaying an error. [#3128](https://github.com/zowe/zowe-explorer-vscode/issues/3128)
- Fixed issue with object based parameter being passed to VS Code's localization API.

## `3.0.0-next.202409132122`

Expand Down
21 changes: 6 additions & 15 deletions packages/zowe-explorer/__tests__/__mocks__/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -865,22 +865,13 @@ export interface Memento {
}

export namespace l10n {
export function t(
options:
| {
message: string;
args?: Array<string | number | boolean> | Record<string, any>;
comment?: string | string[];
}
| string
): string {
if (typeof options === "string") {
return options;
export function t(message: string, args?: string[]): string {
if (args && Array.isArray(args) && args.length) {
args.forEach((arg, i) => {
message = message.replace(`{${i}}`, arg);
});
}
options.args?.forEach((arg: string, i: number) => {
options.message = options.message.replace(`{${i}}`, arg);
});
return options.message;
return message;
}
}

Expand Down
Loading
Loading