11import * as fs from 'fs-extra' ;
22import * 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' ;
44import { PythonProject , PythonProjectCreator , PythonProjectCreatorOptions } from '../../api' ;
55import { NEW_PROJECT_TEMPLATES_FOLDER } from '../../common/constants' ;
66import { showInputBoxWithButtons } from '../../common/window.apis' ;
@@ -15,10 +15,10 @@ import {
1515} from './creationHelpers' ;
1616
1717export 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 - z 0 - 9 _ ] [ a - z 0 - 9 . _ - ] * [ a - z 0 - 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