@@ -91,17 +91,32 @@ export class InputDialogComponent implements LanguageUpdateable {
9191 cancelText ?: string
9292 ) : void {
9393 try {
94+ // 获取当前语言配置
9495 const language = LanguageEventManager . getInstance ( ) . getCurrentLanguage ( ) ;
9596
97+ // 检测是否为URL测试对话框并应用正确的语言
98+ const isUrlTestDialog = title . includes ( 'enter the URL' ) ||
99+ title . includes ( 'Please enter the URL' ) ||
100+ title . includes ( '请输入要测试的URL' ) ;
101+
102+ if ( isUrlTestDialog && language ) {
103+ // 使用当前语言的URL测试提示
104+ title = language . debugger_config . urlPatternTestPrompt ;
105+ placeholder = language . debugger_config . urlPatternTextPlaceholder ;
106+ okText = language . basic . testButton ;
107+ cancelText = language . basic . inputDialog . defaultCancelText ;
108+ logger . debug ( `检测到URL测试对话框,应用当前语言的文本配置` ) ;
109+ }
110+
96111 // 保存当前配置
97112 this . currentConfig = {
98113 title,
99114 message,
100115 callback,
101116 defaultValue,
102117 placeholder,
103- okText : okText || language ?. basic . inputDialog . defaultOkText || 'OK' ,
104- cancelText : cancelText || language ?. basic . inputDialog . defaultCancelText || 'Cancel'
118+ okText : okText || ( language ?. basic . inputDialog . defaultOkText || 'OK' ) ,
119+ cancelText : cancelText || ( language ?. basic . inputDialog . defaultCancelText || 'Cancel' )
105120 } ;
106121
107122 this . appendStyles ( ) ;
@@ -231,33 +246,61 @@ export class InputDialogComponent implements LanguageUpdateable {
231246 return ;
232247 }
233248
249+ // 更新对话框标题
250+ const header = this . dialogElement . querySelector ( '.js-script-hook-input-dialog-header' ) ;
251+ if ( header ) {
252+ // 保存图标元素
253+ const iconSpan = header . querySelector ( '.js-script-hook-input-dialog-icon' ) ;
254+ const iconHtml = iconSpan ? iconSpan . outerHTML : '' ;
255+
256+ // 检查标题是否需要本地化
257+ if ( this . currentConfig . title . includes ( 'enter the URL' ) ||
258+ this . currentConfig . title . includes ( 'Please enter the URL' ) ||
259+ this . currentConfig . title . includes ( '请输入要测试的URL' ) ) {
260+ // 检测到是URL测试对话框,使用对应语言的提示文本
261+ header . innerHTML = iconHtml + language . debugger_config . urlPatternTestPrompt ;
262+ logger . debug ( `已将对话框标题更新为URL测试提示: ${ language . debugger_config . urlPatternTestPrompt } ` ) ;
263+ }
264+ }
265+
234266 // 更新确认按钮文本
235267 const okButton = this . dialogElement . querySelector ( '.js-script-hook-input-dialog-ok-btn' ) as HTMLButtonElement ;
236268 if ( okButton ) {
237- okButton . textContent = this . currentConfig . okText ;
269+ // 检查是否为测试按钮
270+ if ( this . currentConfig . okText === 'Test' ||
271+ this . currentConfig . okText === '测试' ||
272+ this . currentConfig . okText === language . basic . testButton ) {
273+ okButton . textContent = language . basic . testButton ;
274+ logger . debug ( `已将确认按钮更新为测试按钮: ${ language . basic . testButton } ` ) ;
275+ } else {
276+ okButton . textContent = language . basic . inputDialog . defaultOkText ;
277+ }
238278 }
239279
240280 // 更新取消按钮文本
241281 const cancelButton = this . dialogElement . querySelector ( '.js-script-hook-input-dialog-cancel-btn' ) as HTMLButtonElement ;
242282 if ( cancelButton ) {
243- cancelButton . textContent = this . currentConfig . cancelText ;
283+ cancelButton . textContent = language . basic . inputDialog . defaultCancelText ;
284+ logger . debug ( `已将取消按钮更新为: ${ language . basic . inputDialog . defaultCancelText } ` ) ;
244285 }
245286
246287 // 更新输入框的placeholder
247288 const inputField = this . dialogElement . querySelector ( '.js-script-hook-input-dialog-input' ) as HTMLInputElement ;
248- if ( inputField && this . currentConfig . placeholder ) {
289+ if ( inputField ) {
249290 // 如果当前placeholder是URL pattern相关的提示文本
250- if ( this . currentConfig . placeholder . includes ( 'Enter a keyword' ) ||
291+ if ( this . currentConfig . placeholder === language . debugger_config . urlPatternTextPlaceholder ||
292+ this . currentConfig . placeholder . includes ( 'Enter a keyword' ) ||
251293 this . currentConfig . placeholder . includes ( '输入关键字' ) ) {
252294 inputField . placeholder = language . debugger_config . urlPatternTextPlaceholder ;
295+ logger . debug ( `已将输入框占位符更新为URL匹配提示: ${ language . debugger_config . urlPatternTextPlaceholder } ` ) ;
253296 }
254297 // 如果当前placeholder是JSONP回调函数参数名相关的提示文本
255298 else if ( this . currentConfig . placeholder . includes ( 'If not specified' ) ||
256299 this . currentConfig . placeholder . includes ( '不指定的话' ) ) {
257300 inputField . placeholder = language . debugger_config . callbackFunctionParamNamePlaceholder ;
258301 }
259302 // 如果是其他类型的placeholder,保持原样
260- else {
303+ else if ( this . currentConfig . placeholder ) {
261304 inputField . placeholder = this . currentConfig . placeholder ;
262305 }
263306 }
0 commit comments