@@ -57,6 +57,9 @@ export class ExtensionManager {
5757 // Set up file system watchers
5858 this . setupFileSystemWatchers ( ) ;
5959
60+ // Register command palette commands
61+ this . registerCommands ( ) ;
62+
6063 this . logger . info ( 'PowerShell Localization extension activated successfully' ) ;
6164
6265 } catch ( error ) {
@@ -130,6 +133,40 @@ export class ExtensionManager {
130133 this . context . subscriptions . push ( psm1Watcher , psd1Watcher ) ;
131134 }
132135
136+ /**
137+ * Registers command palette commands
138+ */
139+ private registerCommands ( ) : void {
140+ // Register switch UI culture command
141+ const switchCommand = vscode . commands . registerCommand (
142+ 'powershellLocalization.switchUICulture' ,
143+ async ( ) => {
144+ await this . handleSwitchUICulture ( ) ;
145+ }
146+ ) ;
147+
148+ // Register set to en-US command
149+ const setEnUsCommand = vscode . commands . registerCommand (
150+ 'powershellLocalization.setUICultureToEnUs' ,
151+ async ( ) => {
152+ await this . handleSetUICulture ( 'en-US' ) ;
153+ }
154+ ) ;
155+
156+ // Register set to fr-FR command
157+ const setFrFrCommand = vscode . commands . registerCommand (
158+ 'powershellLocalization.setUICultureToFrFr' ,
159+ async ( ) => {
160+ await this . handleSetUICulture ( 'fr-FR' ) ;
161+ }
162+ ) ;
163+
164+ this . disposables . push ( switchCommand , setEnUsCommand , setFrFrCommand ) ;
165+ this . context . subscriptions . push ( switchCommand , setEnUsCommand , setFrFrCommand ) ;
166+
167+ this . logger . info ( 'Command palette commands registered' ) ;
168+ }
169+
133170 /**
134171 * Handles configuration changes
135172 */
@@ -163,6 +200,57 @@ export class ExtensionManager {
163200 }
164201 }
165202
203+ /**
204+ * Handles switching UI culture via input box
205+ */
206+ private async handleSwitchUICulture ( ) : Promise < void > {
207+ try {
208+ const currentCulture = ConfigurationManager . getUICulture ( ) ;
209+ const inputCulture = await vscode . window . showInputBox ( {
210+ prompt : 'Enter UI Culture (e.g., en-US, fr-FR, de-DE)' ,
211+ value : currentCulture ,
212+ validateInput : ( value ) => {
213+ const culturePattern = / ^ [ a - z ] { 2 } ( - [ A - Z ] { 2 } ) ? $ / ;
214+ if ( ! culturePattern . test ( value ) ) {
215+ return 'Invalid culture format. Use format like "en-US", "fr-FR", "de-DE"' ;
216+ }
217+ return null ;
218+ }
219+ } ) ;
220+
221+ if ( inputCulture && inputCulture !== currentCulture ) {
222+ await this . handleSetUICulture ( inputCulture ) ;
223+ }
224+ } catch ( error ) {
225+ this . logger . error ( 'Failed to switch UI culture' , error as Error ) ;
226+ vscode . window . showErrorMessage ( `Failed to switch UI culture: ${ ( error as Error ) . message } ` ) ;
227+ }
228+ }
229+
230+ /**
231+ * Handles setting UI culture to a specific value
232+ */
233+ private async handleSetUICulture ( culture : string ) : Promise < void > {
234+ try {
235+ const currentCulture = ConfigurationManager . getUICulture ( ) ;
236+ if ( culture === currentCulture ) {
237+ vscode . window . showInformationMessage ( `UI Culture is already set to ${ culture } ` ) ;
238+ return ;
239+ }
240+
241+ await ConfigurationManager . setUICulture ( culture ) ;
242+
243+ // Clear the cache since culture has changed
244+ this . decorationProvider . clearCache ( ) ;
245+
246+ vscode . window . showInformationMessage ( `UI Culture changed to ${ culture } ` ) ;
247+ this . logger . info ( `UI Culture changed from ${ currentCulture } to ${ culture } ` ) ;
248+ } catch ( error ) {
249+ this . logger . error ( `Failed to set UI culture to ${ culture } ` , error as Error ) ;
250+ vscode . window . showErrorMessage ( `Failed to set UI culture: ${ ( error as Error ) . message } ` ) ;
251+ }
252+ }
253+
166254 /**
167255 * Disposes of all resources
168256 */
0 commit comments