|
9 | 9 | // Ctrl-G (or whatever is bound to findNext) press. You prevent a |
10 | 10 | // replace by making sure the match is no longer selected when hitting |
11 | 11 | // Ctrl-G. |
| 12 | +import i18n from '../i18n'; |
12 | 13 |
|
13 | 14 | export default function(CodeMirror) { |
14 | 15 | "use strict"; |
@@ -85,7 +86,7 @@ export default function(CodeMirror) { |
85 | 86 | else if (e.keyCode !== 13 && searchField.value.length > 1) { // not enter and more than 1 character to search |
86 | 87 | startSearch(cm, getSearchState(cm), searchField.value); |
87 | 88 | } else if (searchField.value.length <= 1) { |
88 | | - cm.display.wrapper.querySelector('.CodeMirror-search-results').innerText = 'No results'; |
| 89 | + cm.display.wrapper.querySelector('.CodeMirror-search-results').innerText = i18n.t('CodemirrorFindAndReplace.NoResults'); |
89 | 90 | } |
90 | 91 | }); |
91 | 92 |
|
@@ -329,6 +330,7 @@ export default function(CodeMirror) { |
329 | 330 | return findNext(cm, rev); |
330 | 331 | } |
331 | 332 | var q = cm.getSelection() || state.lastQuery; |
| 333 | + var queryDialog = getQueryDialog(); |
332 | 334 | if (persistent && cm.openDialog) { |
333 | 335 | var hiding = null; |
334 | 336 | var searchNext = function(query, event) { |
@@ -382,7 +384,7 @@ export default function(CodeMirror) { |
382 | 384 | if (!cursor.find(rev)) { |
383 | 385 | cursor = getSearchCursor(cm, state.query, rev ? CodeMirror.Pos(cm.lastLine()) : CodeMirror.Pos(cm.firstLine(), 0)); |
384 | 386 | if (!cursor.find(rev)) { |
385 | | - cm.display.wrapper.querySelector('.CodeMirror-search-results').innerText = 'No results'; |
| 387 | + cm.display.wrapper.querySelector('.CodeMirror-search-results').innerText = i18n.t('CodemirrorFindAndReplace.NoResults'); |
386 | 388 | return; |
387 | 389 | } |
388 | 390 | } |
@@ -418,100 +420,102 @@ export default function(CodeMirror) { |
418 | 420 | }); |
419 | 421 | } |
420 | 422 |
|
421 | | - var queryDialog = ` |
422 | | - <div class="CodeMirror-find-popup-container"> |
423 | | - <div class="Toggle-replace-btn-div"> |
424 | | - <button |
425 | | - title="Replace" |
426 | | - aria-label="Replace" |
427 | | - role="button" |
428 | | - class="CodeMirror-search-modifier-button CodeMirror-replace-toggle-button" |
429 | | - > |
430 | | - <span aria-hidden="true" class="button">▶</span> |
431 | | - </button> |
432 | | - </div> |
433 | | - <div class="CodeMirror-find-input-fields"> |
434 | | - <div class="CodeMirror-find-div"> |
435 | | - <div class="CodeMirror-find-input"> |
436 | | - <input id="Find-input-field" type="text" class="search-input CodeMirror-search-field" placeholder="Find in files" /> |
437 | | - </div> |
438 | | - <div class="CodeMirror-find-controls"> |
439 | | - <div class="CodeMirror-search-modifiers button-wrap"> |
440 | | - <button |
441 | | - title="Regular expression" |
442 | | - aria-label="Regular expression" |
443 | | - role="checkbox" |
444 | | - class="CodeMirror-search-modifier-button CodeMirror-regexp-button" |
445 | | - > |
446 | | - <span aria-hidden="true" class="button">.*</span> |
447 | | - </button> |
448 | | - <button |
449 | | - title="Case sensitive" |
450 | | - aria-label="Case sensitive" |
451 | | - role="checkbox" |
452 | | - class="CodeMirror-search-modifier-button CodeMirror-case-button" |
453 | | - > |
454 | | - <span aria-hidden="true" class="button">Aa</span> |
455 | | - </button> |
456 | | - <button |
457 | | - title="Whole words" |
458 | | - aria-label="Whole words" |
459 | | - role="checkbox" |
460 | | - class="CodeMirror-search-modifier-button CodeMirror-word-button" |
461 | | - > |
462 | | - <span aria-hidden="true" class="button">" "</span> |
463 | | - </button> |
| 423 | + var getQueryDialog = function() { |
| 424 | + return (` |
| 425 | + <div class="CodeMirror-find-popup-container"> |
| 426 | + <div class="Toggle-replace-btn-div"> |
| 427 | + <button |
| 428 | + title="${i18n.t('CodemirrorFindAndReplace.Replace')}" |
| 429 | + aria-label="${i18n.t('CodemirrorFindAndReplace.Replace')}" |
| 430 | + role="button" |
| 431 | + class="CodeMirror-search-modifier-button CodeMirror-replace-toggle-button" |
| 432 | + > |
| 433 | + <span aria-hidden="true" class="button">▶</span> |
| 434 | + </button> |
| 435 | + </div> |
| 436 | + <div class="CodeMirror-find-input-fields"> |
| 437 | + <div class="CodeMirror-find-div"> |
| 438 | + <div class="CodeMirror-find-input"> |
| 439 | + <input id="Find-input-field" type="text" class="search-input CodeMirror-search-field" placeholder="${i18n.t('CodemirrorFindAndReplace.FindPlaceholder')}" /> |
| 440 | + </div> |
| 441 | + <div class="CodeMirror-find-controls"> |
| 442 | + <div class="CodeMirror-search-modifiers button-wrap"> |
| 443 | + <button |
| 444 | + title="${i18n.t('CodemirrorFindAndReplace.Regex')}" |
| 445 | + aria-label="${i18n.t('CodemirrorFindAndReplace.Regex')}" |
| 446 | + role="checkbox" |
| 447 | + class="CodeMirror-search-modifier-button CodeMirror-regexp-button" |
| 448 | + > |
| 449 | + <span aria-hidden="true" class="button">.*</span> |
| 450 | + </button> |
| 451 | + <button |
| 452 | + title="${i18n.t('CodemirrorFindAndReplace.CaseSensitive')}" |
| 453 | + aria-label="${i18n.t('CodemirrorFindAndReplace.CaseSensitive')}" |
| 454 | + role="checkbox" |
| 455 | + class="CodeMirror-search-modifier-button CodeMirror-case-button" |
| 456 | + > |
| 457 | + <span aria-hidden="true" class="button">Aa</span> |
| 458 | + </button> |
| 459 | + <button |
| 460 | + title="${i18n.t('CodemirrorFindAndReplace.WholeWords')}" |
| 461 | + aria-label="${i18n.t('CodemirrorFindAndReplace.WholeWords')}" |
| 462 | + role="checkbox" |
| 463 | + class="CodeMirror-search-modifier-button CodeMirror-word-button" |
| 464 | + > |
| 465 | + <span aria-hidden="true" class="button">" "</span> |
| 466 | + </button> |
| 467 | + </div> |
| 468 | + <div class="CodeMirror-search-nav"> |
| 469 | + <p class="CodeMirror-search-results">${i18n.t('CodemirrorFindAndReplace.NoResults')}</p> |
| 470 | + <button |
| 471 | + title="${i18n.t('CodemirrorFindAndReplace.Previous')}" |
| 472 | + aria-label="${i18n.t('CodemirrorFindAndReplace.Previous')}" |
| 473 | + class="CodeMirror-search-button icon up-arrow prev" |
| 474 | + > |
| 475 | + </button> |
| 476 | + <button |
| 477 | + title="${i18n.t('CodemirrorFindAndReplace.Next')}" |
| 478 | + aria-label="${i18n.t('CodemirrorFindAndReplace.Next')}" |
| 479 | + class="CodeMirror-search-button icon down-arrow next" |
| 480 | + > |
| 481 | + </button> |
| 482 | + </div> |
| 483 | + <div class="CodeMirror-close-button-container"> |
| 484 | + <button |
| 485 | + title="${i18n.t('CodemirrorFindAndReplace.Close')}" |
| 486 | + aria-label="${i18n.t('CodemirrorFindAndReplace.Close')}" |
| 487 | + class="CodeMirror-close-button close icon"> |
| 488 | + </button> |
| 489 | + </div> |
464 | 490 | </div> |
465 | | - <div class="CodeMirror-search-nav"> |
466 | | - <p class="CodeMirror-search-results">No results</p> |
| 491 | + </div> |
| 492 | + <div style="height: 0px; overflow: hidden;" class="CodeMirror-replace-div"> |
| 493 | + <input id="Replace-input-field" type="text" placeholder="${i18n.t('CodemirrorFindAndReplace.ReplacePlaceholder')}" class="search-input CodeMirror-search-field"/> |
| 494 | + <div class="CodeMirror-replace-controls"> |
467 | 495 | <button |
468 | | - title="Previous" |
469 | | - aria-label="Previous" |
470 | | - class="CodeMirror-search-button icon up-arrow prev" |
| 496 | + title="${i18n.t('CodemirrorFindAndReplace.Replace')}" |
| 497 | + aria-label="${i18n.t('CodemirrorFindAndReplace.Replace')}" |
| 498 | + role="button" |
| 499 | + id="Btn-replace" |
| 500 | + class="CodeMirror-search-modifier-button CodeMirror-replace-button" |
471 | 501 | > |
| 502 | + ${i18n.t('CodemirrorFindAndReplace.Replace')} |
472 | 503 | </button> |
473 | 504 | <button |
474 | | - title="Next" |
475 | | - aria-label="Next" |
476 | | - class="CodeMirror-search-button icon down-arrow next" |
| 505 | + title="${i18n.t('CodemirrorFindAndReplace.ReplaceAll')}" |
| 506 | + aria-label="${i18n.t('CodemirrorFindAndReplace.ReplaceAll')}" |
| 507 | + role="button" |
| 508 | + id="Btn-replace-all" |
| 509 | + class="CodeMirror-search-modifier-button CodeMirror-replace-button" |
477 | 510 | > |
478 | | - </button> |
479 | | - </div> |
480 | | - <div class="CodeMirror-close-button-container"> |
481 | | - <button |
482 | | - title="Close" |
483 | | - aria-label="Close" |
484 | | - class="CodeMirror-close-button close icon"> |
| 511 | + ${i18n.t('CodemirrorFindAndReplace.ReplaceAll')} |
485 | 512 | </button> |
486 | 513 | </div> |
487 | 514 | </div> |
488 | 515 | </div> |
489 | | - <div style="height: 0px; overflow: hidden;" class="CodeMirror-replace-div"> |
490 | | - <input id="Replace-input-field" type="text" placeholder="Text to replace" class="search-input CodeMirror-search-field"/> |
491 | | - <div class="CodeMirror-replace-controls"> |
492 | | - <button |
493 | | - title="Replace" |
494 | | - aria-label="Replace" |
495 | | - role="button" |
496 | | - id="Btn-replace" |
497 | | - class="CodeMirror-search-modifier-button CodeMirror-replace-button" |
498 | | - > |
499 | | - Replace |
500 | | - </button> |
501 | | - <button |
502 | | - title="Replace All" |
503 | | - aria-label="Replace All" |
504 | | - role="button" |
505 | | - id="Btn-replace-all" |
506 | | - class="CodeMirror-search-modifier-button CodeMirror-replace-button" |
507 | | - > |
508 | | - Replace All |
509 | | - </button> |
510 | | - </div> |
511 | | - </div> |
512 | 516 | </div> |
513 | | - </div> |
514 | | - `; |
| 517 | + `); |
| 518 | + } |
515 | 519 |
|
516 | 520 | CodeMirror.commands.findPersistent = function(cm) {doFindAndReplace(cm, false, true, false, true, false);}; |
517 | 521 | CodeMirror.commands.findPersistentNext = function(cm) {doFindAndReplace(cm, false, true, false, true, false);}; |
|
0 commit comments