Bug 919706 - Localize search UI. r=robcee
authorAnton Kovalyov <anton@mozilla.com>
Wed, 23 Oct 2013 14:57:13 -0700
changeset 165628 684d1c36eace12b366735d36d174f0787b0e5c97
parent 165627 1bab2224b51a05a1bab282dc04f4c74dc5d4870c
child 165629 4ceaf2926e5bb78116055ce1b66d88ff41295330
child 165877 e095e2f442f847d77fe563623d0f58f87b7ae643
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrobcee
bugs919706
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 919706 - Localize search UI. r=robcee
browser/devtools/sourceeditor/codemirror/README
browser/devtools/sourceeditor/codemirror/search/search.js
browser/devtools/sourceeditor/editor.js
--- a/browser/devtools/sourceeditor/codemirror/README
+++ b/browser/devtools/sourceeditor/codemirror/README
@@ -13,18 +13,19 @@ To confirm the functionality run mochite
 
  * sourceeditor
  * scratchpad
  * debugger
  * styleditor
 
 The sourceeditor component contains imported CodeMirror tests [3]. Some
 tests were commented out because we don't use that functionality within
-Firefox (for example Ruby editing mode). Other than that, we don't have
-any Mozilla-specific patches applied to CodeMirror itself.
+Firefox (for example Ruby editing mode). The search addon (search.js)
+was slightly modified to make search UI localizable. Other than that,
+we don't have any Mozilla-specific patches applied to CodeMirror itself.
 
 # Addons
 
 To install a new CodeMirror addon add it to the codemirror directory,
 jar.mn [4] file and editor.js [5]. Also, add it to the License section
 below.
 
 # License
--- a/browser/devtools/sourceeditor/codemirror/search/search.js
+++ b/browser/devtools/sourceeditor/codemirror/search/search.js
@@ -40,22 +40,26 @@
   function confirmDialog(cm, text, shortText, fs) {
     if (cm.openConfirm) cm.openConfirm(text, fs);
     else if (confirm(shortText)) fs[0]();
   }
   function parseQuery(query) {
     var isRE = query.match(/^\/(.*)\/([a-z]*)$/);
     return isRE ? new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i") : query;
   }
-  var queryDialog =
-    'Search: <input type="text" style="width: 10em"/> <span style="color: #888">(Use /re/ syntax for regexp search)</span>';
+  var queryDialog;
   function doSearch(cm, rev) {
+    if (!queryDialog) {
+      queryDialog = cm.l10n('findCmd.promptMessage') +
+        ' <input type="text" style="width: 10em"/>';
+    }
+
     var state = getSearchState(cm);
     if (state.query) return findNext(cm, rev);
-    dialog(cm, queryDialog, "Search for:", function(query) {
+    dialog(cm, queryDialog, cm.l10n('findCmd.promptMessage'), function(query) {
       cm.operation(function() {
         if (!query || state.query) return;
         state.query = parseQuery(query);
         cm.removeOverlay(state.overlay);
         state.overlay = searchOverlay(state.query);
         cm.addOverlay(state.overlay);
         state.posFrom = state.posTo = cm.getCursor();
         findNext(cm, rev);
--- a/browser/devtools/sourceeditor/editor.js
+++ b/browser/devtools/sourceeditor/editor.js
@@ -202,16 +202,20 @@ Editor.prototype = {
         this.emit("contextMenu");
         this.showContextMenu(doc, ev.screenX, ev.screenY);
       }, false);
 
       cm.on("change", () => this.emit("change"));
       cm.on("gutterClick", (cm, line) => this.emit("gutterClick", line));
       cm.on("cursorActivity", (cm) => this.emit("cursorActivity"));
 
+      win.CodeMirror.defineExtension("l10n", (name) => {
+        return L10N.GetStringFromName(name);
+      });
+
       doc.defaultView.controllers.insertControllerAt(0, controller(this, doc.defaultView));
 
       this.container = env;
       editors.set(this, cm);
       def.resolve();
     };
 
     env.addEventListener("load", onLoad, true);