Skip to content

Commit ba917f9

Browse files
committed
use l10n
1 parent 7bf6193 commit ba917f9

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

src/common/pickers/managers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ export async function newProjectSelection(creators: PythonProjectCreator[]): Pro
202202
return undefined;
203203
}
204204
// Handle back button
205+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
205206
if ((newSelected as any)?.kind === -1 || (newSelected as any)?.back === true) {
206207
// User pressed the back button, re-show the first menu
207208
return pickCreator(creators);

src/features/creators/creationHelpers.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as fs from 'fs-extra';
22
import * as path from 'path';
3-
import { extensions, QuickInputButtons, Uri, window } from 'vscode';
3+
import { extensions, l10n, QuickInputButtons, Uri, window } from 'vscode';
44
import { CreateEnvironmentOptions } from '../../api';
55
import { traceError, traceVerbose } from '../../common/logging';
66
import { showQuickPickWithButtons } from '../../common/window.apis';
@@ -12,8 +12,8 @@ import { EnvironmentManagers, InternalEnvironmentManager } from '../../internal.
1212
*/
1313
export async function promptForVenv(callback: () => void): Promise<boolean | undefined> {
1414
try {
15-
const venvChoice = await showQuickPickWithButtons([{ label: 'Yes' }, { label: 'No' }], {
16-
placeHolder: 'Would you like to create a new virtual environment for this project?',
15+
const venvChoice = await showQuickPickWithButtons([{ label: l10n.t('Yes') }, { label: l10n.t('No') }], {
16+
placeHolder: l10n.t('Would you like to create a new virtual environment for this project?'),
1717
ignoreFocusOut: true,
1818
showBackButton: true,
1919
});

src/features/creators/newPackageProject.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as fs from 'fs-extra';
22
import * as path from 'path';
3-
import { commands, MarkdownString, QuickInputButtons, Uri, window, workspace } from 'vscode';
3+
import { commands, l10n, MarkdownString, QuickInputButtons, Uri, window, workspace } from 'vscode';
44
import { PythonProject, PythonProjectCreator, PythonProjectCreatorOptions } from '../../api';
55
import { NEW_PROJECT_TEMPLATES_FOLDER } from '../../common/constants';
66
import { showInputBoxWithButtons } from '../../common/window.apis';
@@ -15,10 +15,10 @@ import {
1515
} from './creationHelpers';
1616

1717
export class NewPackageProject implements PythonProjectCreator {
18-
public readonly name = 'newPackage';
19-
public readonly displayName = 'Package';
20-
public readonly description = 'Creates a package folder in your current workspace';
21-
public readonly tooltip = new MarkdownString('Create a new Python package');
18+
public readonly name = l10n.t('newPackage');
19+
public readonly displayName = l10n.t('Package');
20+
public readonly description = l10n.t('Creates a package folder in your current workspace');
21+
public readonly tooltip = new MarkdownString(l10n.t('Create a new Python package'));
2222

2323
constructor(private readonly envManagers: EnvironmentManagers) {}
2424

@@ -38,16 +38,18 @@ export class NewPackageProject implements PythonProjectCreator {
3838
if (!packageName) {
3939
try {
4040
packageName = await showInputBoxWithButtons({
41-
prompt: 'What is the name of the package? (e.g. my_package)',
41+
prompt: l10n.t('What is the name of the package? (e.g. my_package)'),
4242
ignoreFocusOut: true,
4343
showBackButton: true,
4444
validateInput: (value) => {
4545
// following PyPI (PEP 508) rules for package names
4646
if (!/^([a-z_]|[a-z0-9_][a-z0-9._-]*[a-z0-9_])$/i.test(value)) {
47-
return 'Invalid package name. Use only letters, numbers, underscores, hyphens, or periods. Must start and end with a letter or number.';
47+
return l10n.t(
48+
'Invalid package name. Use only letters, numbers, underscores, hyphens, or periods. Must start and end with a letter or number.',
49+
);
4850
}
4951
if (/^[-._0-9]$/i.test(value)) {
50-
return 'Single-character package names cannot be a number, hyphen, or period.';
52+
return l10n.t('Single-character package names cannot be a number, hyphen, or period.');
5153
}
5254
return null;
5355
},
@@ -73,14 +75,10 @@ export class NewPackageProject implements PythonProjectCreator {
7375
}
7476
}
7577

76-
window.showInformationMessage(
77-
`Creating a new Python project: ${packageName}\nvenv: ${createVenv}\nCopilot instructions: ${createCopilotInstructions}`,
78-
);
79-
8078
// 1. Copy template folder
8179
const newPackageTemplateFolder = path.join(NEW_PROJECT_TEMPLATES_FOLDER, 'newPackageTemplate');
8280
if (!(await fs.pathExists(newPackageTemplateFolder))) {
83-
window.showErrorMessage('Template folder does not exist, aborting creation.');
81+
window.showErrorMessage(l10n.t('Template folder does not exist, aborting creation.'));
8482
return undefined;
8583
}
8684

@@ -89,7 +87,7 @@ export class NewPackageProject implements PythonProjectCreator {
8987
if (!destRoot) {
9088
const workspaceFolders = workspace.workspaceFolders;
9189
if (!workspaceFolders || workspaceFolders.length === 0) {
92-
window.showErrorMessage('No workspace folder is open or provided, aborting creation.');
90+
window.showErrorMessage(l10n.t('No workspace folder is open or provided, aborting creation.'));
9391
return undefined;
9492
}
9593
destRoot = workspaceFolders[0].uri.fsPath;
@@ -99,7 +97,9 @@ export class NewPackageProject implements PythonProjectCreator {
9997
const projectDestinationFolder = path.join(destRoot, `${packageName}_project`);
10098
if (await fs.pathExists(projectDestinationFolder)) {
10199
window.showErrorMessage(
102-
'A project folder by that name already exists, aborting creation. Please retry with a unique package name given your workspace.',
100+
l10n.t(
101+
'A project folder by that name already exists, aborting creation. Please retry with a unique package name given your workspace.',
102+
),
103103
);
104104
return undefined;
105105
}
@@ -118,7 +118,7 @@ export class NewPackageProject implements PythonProjectCreator {
118118
const pythonEnvironment = await this.envManagers.getEnvironment(Uri.parse(projectDestinationFolder));
119119

120120
if (!pythonEnvironment) {
121-
window.showErrorMessage('Python environment not found.');
121+
window.showErrorMessage(l10n.t('Python environment not found.'));
122122
return undefined;
123123
}
124124

0 commit comments

Comments
 (0)