Bug 1340971 - Use proper plural form in editor.searchResults and sourceSearch.resultsSummary1 r=davidwalsh,flod
authorMiriam <bmiriam1230@gmail.com>
Tue, 11 Jun 2019 19:25:15 +0000
changeset 478325 65258ed1ea60bc841a784c5c9010c76d3c0db6b6
parent 478324 138edceae4d995226438a92797fd29ab9140cab3
child 478326 fbf7d1f93ce6af461061d963a04113c8148e8ed0
push id36140
push userdluca@mozilla.com
push dateWed, 12 Jun 2019 12:02:49 +0000
treeherdermozilla-central@6b172dc138ee [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavidwalsh, flod
bugs1340971
milestone69.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 1340971 - Use proper plural form in editor.searchResults and sourceSearch.resultsSummary1 r=davidwalsh,flod Added proper plural form to editor.searchResults and sourceSearch.resultsSummary1. Updated the comments and IDs for the new strings as well. Replaced all instances of old string references with new string references. Differential Revision: https://phabricator.services.mozilla.com/D32881
devtools/client/debugger/package.json
devtools/client/debugger/packages/devtools-reps/package.json
devtools/client/debugger/src/components/Editor/SearchBar.js
devtools/client/debugger/src/components/Editor/tests/__snapshots__/SearchBar.spec.js.snap
devtools/client/debugger/src/components/ProjectSearch.js
devtools/client/debugger/yarn.lock
devtools/client/locales/en-US/debugger.properties
devtools/client/shared/build/build-debugger.js
devtools/shared/plural-form.js
--- a/devtools/client/debugger/package.json
+++ b/devtools/client/debugger/package.json
@@ -49,17 +49,17 @@
   "dependencies": {
     "@babel/core": "^7.0.0-beta.55",
     "@babel/parser": "^7.0.0-beta.55",
     "@babel/template": "^7.0.0-beta.55",
     "@babel/types": "^7.0.0-beta.55",
     "babel-plugin-transform-imports": "^1.5.0",
     "codemirror": "^5.28.0",
     "devtools-environment": "^0.0.6",
-    "devtools-launchpad": "^0.0.154",
+    "devtools-launchpad": "^0.0.155",
     "devtools-linters": "^0.0.4",
     "devtools-reps": "0.23.0",
     "devtools-source-map": "0.16.0",
     "devtools-splitter": "^0.0.8",
     "devtools-utils": "0.0.14",
     "fuzzaldrin-plus": "^0.6.0",
     "lodash": "^4.17.4",
     "lodash-move": "^1.1.1",
--- a/devtools/client/debugger/packages/devtools-reps/package.json
+++ b/devtools/client/debugger/packages/devtools-reps/package.json
@@ -33,17 +33,17 @@
     "redux": "^3.7.2"
   },
   "devDependencies": {
     "@sucrase/webpack-object-rest-spread-plugin": "^1.0.0",
     "babel-plugin-syntax-object-rest-spread": "^6.13.0",
     "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
     "babel-preset-react": "^6.24.1",
     "devtools-config": "^0.0.16",
-    "devtools-launchpad": "^0.0.154",
+    "devtools-launchpad": "^0.0.155",
     "devtools-license-check": "^0.7.0",
     "devtools-modules": "~1.1.0",
     "devtools-services": "^0.0.1",
     "enzyme": "^3.3.0",
     "enzyme-adapter-react-16": "^1.1.1",
     "enzyme-to-json": "^3.3.1",
     "eslint": "^5.0.0",
     "eslint-plugin-mozilla": "1.1.3",
--- a/devtools/client/debugger/src/components/Editor/SearchBar.js
+++ b/devtools/client/debugger/src/components/Editor/SearchBar.js
@@ -28,16 +28,17 @@ import { scrollList } from "../../utils/
 import classnames from "classnames";
 
 import type { Source, Context } from "../../types";
 import type { Modifiers, SearchResults } from "../../reducers/file-search";
 
 import SearchInput from "../shared/SearchInput";
 import { debounce } from "lodash";
 import "./SearchBar.css";
+import { PluralForm } from "devtools-modules";
 
 import type SourceEditor from "../../utils/editor/source-editor";
 
 function getShortcuts() {
   const searchAgainKey = L10N.getStr("sourceSearch.search.again.key3");
   const searchAgainPrevKey = L10N.getStr("sourceSearch.search.againPrev.key3");
   const searchKey = L10N.getStr("sourceSearch.search.key2");
 
@@ -234,20 +235,24 @@ class SearchBar extends Component<Props,
       return "";
     }
 
     if (count == 0) {
       return L10N.getStr("editor.noResultsFound");
     }
 
     if (index == -1) {
-      return L10N.getFormatStr("sourceSearch.resultsSummary1", count);
+      const resultsSummaryString = L10N.getStr("sourceSearch.resultsSummary1");
+      return PluralForm.get(count, resultsSummaryString).replace("#1", count);
     }
 
-    return L10N.getFormatStr("editor.searchResults", matchIndex + 1, count);
+    const searchResultsString = L10N.getStr("editor.searchResults1");
+    return PluralForm.get(count, searchResultsString)
+      .replace("#1", count)
+      .replace("%d", matchIndex + 1);
   }
 
   renderSearchModifiers = () => {
     const { cx, modifiers, toggleFileSearchModifier, query } = this.props;
     const { doSearch } = this;
 
     function SearchModBtn({ modVal, className, svgName, tooltip }) {
       const preppedClass = classnames(className, {
--- a/devtools/client/debugger/src/components/Editor/tests/__snapshots__/SearchBar.spec.js.snap
+++ b/devtools/client/debugger/src/components/Editor/tests/__snapshots__/SearchBar.spec.js.snap
@@ -161,17 +161,17 @@ exports[`showErrorEmoji false if query +
     onKeyDown={[Function]}
     placeholder="Find in file…"
     query="test"
     selectedItemId=""
     shouldFocus={false}
     showClose={false}
     showErrorEmoji={false}
     size=""
-    summaryMsg="-NaN of 10 results"
+    summaryMsg="NaN of 10 results"
   />
   <div
     className="search-bottom-bar"
   >
     <div
       className="search-modifiers"
     >
       <span
--- a/devtools/client/debugger/src/components/ProjectSearch.js
+++ b/devtools/client/debugger/src/components/ProjectSearch.js
@@ -26,16 +26,17 @@ import {
 import ManagedTree from "./shared/ManagedTree";
 import SearchInput from "./shared/SearchInput";
 import AccessibleImage from "./shared/AccessibleImage";
 
 import type { List } from "immutable";
 import type { ActiveSearchType } from "../reducers/types";
 import type { StatusType } from "../reducers/project-text-search";
 import type { Context } from "../types";
+import { PluralForm } from "devtools-modules";
 
 import "./ProjectSearch.css";
 
 export type Match = {
   type: "MATCH",
   sourceId: string,
   line: number,
   column: number,
@@ -275,19 +276,22 @@ export class ProjectSearch extends Compo
     const msg =
       status === statusType.fetching
         ? L10N.getStr("loadingText")
         : L10N.getStr("projectTextSearch.noResults");
     return <div className="no-result-msg absolute-center">{msg}</div>;
   };
 
   renderSummary = () => {
-    return this.props.query !== ""
-      ? L10N.getFormatStr("sourceSearch.resultsSummary1", this.getResultCount())
-      : "";
+    if (this.props.query !== "") {
+      const resultsSummaryString = L10N.getStr("sourceSearch.resultsSummary2");
+      const count = this.getResultCount();
+      return PluralForm.get(count, resultsSummaryString).replace("#1", count);
+    }
+    return "";
   };
 
   shouldShowErrorEmoji() {
     return !this.getResultCount() && this.props.status === statusType.done;
   }
 
   renderInput() {
     const { status } = this.props;
--- a/devtools/client/debugger/yarn.lock
+++ b/devtools/client/debugger/yarn.lock
@@ -3269,33 +3269,33 @@ detective@^4.3.1:
 devtools-config@^0.0.16:
   version "0.0.16"
   resolved "https://registry.yarnpkg.com/devtools-config/-/devtools-config-0.0.16.tgz#e7251788422f42a16aa1372b6adbebfcb7a74994"
 
 devtools-connection@^1.0.7:
   version "1.0.7"
   resolved "https://registry.yarnpkg.com/devtools-connection/-/devtools-connection-1.0.7.tgz#16f23256f842dce339038cdc273c49c473ef83e0"
 
-devtools-contextmenu@~1.0.7:
-  version "1.0.7"
-  resolved "https://registry.yarnpkg.com/devtools-contextmenu/-/devtools-contextmenu-1.0.7.tgz#dd56353a706c3be4cd06d49d6da6dc5219254c90"
-  dependencies:
-    devtools-modules "~1.1.3"
+devtools-contextmenu@~1.0.8:
+  version "1.0.8"
+  resolved "https://registry.yarnpkg.com/devtools-contextmenu/-/devtools-contextmenu-1.0.8.tgz#de57a1afd2324cf48dc251e3e44e3fea1ef9581a"
+  dependencies:
+    devtools-modules "~1.1.4"
 
 devtools-environment@^0.0.5:
   version "0.0.5"
   resolved "https://registry.yarnpkg.com/devtools-environment/-/devtools-environment-0.0.5.tgz#0333bf35009fe09c21c315069e6b4d9177a4b8d1"
 
 devtools-environment@^0.0.6:
   version "0.0.6"
   resolved "https://registry.yarnpkg.com/devtools-environment/-/devtools-environment-0.0.6.tgz#11584f5b1ead784c2356d8da647a630fed591a4e"
 
-devtools-launchpad@^0.0.154:
-  version "0.0.154"
-  resolved "https://registry.yarnpkg.com/devtools-launchpad/-/devtools-launchpad-0.0.154.tgz#ee408dcae5b5e36eca9eb55338eeaf6920a46bf7"
+devtools-launchpad@^0.0.155:
+  version "0.0.155"
+  resolved "https://registry.yarnpkg.com/devtools-launchpad/-/devtools-launchpad-0.0.155.tgz#61b8f3b329df761c6fe82ac619a5bec789049fd0"
   dependencies:
     amd-loader "0.0.8"
     autoprefixer "^7.1.2"
     babel-cli "^6.7.5"
     babel-core "^6.25.0"
     babel-eslint "^7.1.0"
     babel-loader "^7.1.1"
     babel-plugin-module-resolver "^2.2.0"
@@ -3311,21 +3311,21 @@ devtools-launchpad@^0.0.154:
     check-node-version "^3.2.0"
     chrome-remote-interface "0.17.0"
     classnames "^2.2.5"
     co "=4.6.0"
     css-loader "^0.26.1"
     debug "^3.1.0"
     devtools-config "^0.0.16"
     devtools-connection "^1.0.7"
-    devtools-contextmenu "~1.0.7"
+    devtools-contextmenu "~1.0.8"
     devtools-environment "^0.0.5"
     devtools-license-check "^0.7.0"
     devtools-mc-assets "^0.0.7"
-    devtools-modules "~1.1.3"
+    devtools-modules "~1.1.4"
     devtools-sprintf-js "^1.0.3"
     express "^4.13.4"
     express-static "^1.2.5"
     extract-text-webpack-plugin "^3.0.0"
     fs-extra "^2.0.0"
     fuzzaldrin-plus "^0.4.0"
     geckodriver "=1.12.2"
     immutable "^3.7.6"
@@ -3403,19 +3403,19 @@ devtools-mc-assets@^0.0.7:
 
 devtools-modules@~1.1.0:
   version "1.1.0"
   resolved "https://registry.yarnpkg.com/devtools-modules/-/devtools-modules-1.1.0.tgz#57e719367acae4f1d143cc13046ac1ef2b61f8c9"
   dependencies:
     devtools-services "0.0.1"
     punycode "^2.1.0"
 
-devtools-modules@~1.1.3:
-  version "1.1.3"
-  resolved "https://registry.yarnpkg.com/devtools-modules/-/devtools-modules-1.1.3.tgz#4fbeee232263794bd3dd5b314c1a0ae28d76ea6f"
+devtools-modules@~1.1.4:
+  version "1.1.4"
+  resolved "https://registry.yarnpkg.com/devtools-modules/-/devtools-modules-1.1.4.tgz#1a3089118a06225d28572e4890cd6dc0b64308a8"
   dependencies:
     devtools-services "0.0.1"
     punycode "^2.1.0"
 
 devtools-services@0.0.1, devtools-services@^0.0.1:
   version "0.0.1"
   resolved "https://registry.yarnpkg.com/devtools-services/-/devtools-services-0.0.1.tgz#9042600c11d1f4d45cc6ca299588a86fac1fbdd5"
 
--- a/devtools/client/locales/en-US/debugger.properties
+++ b/devtools/client/locales/en-US/debugger.properties
@@ -312,19 +312,20 @@ sourceSearch.search.placeholder2=Find in file…
 sourceSearch.search.again.key3=Cmd+G
 
 # LOCALIZATION NOTE (sourceSearch.search.againPrev.key3): Key shortcut to highlight
 # the previous occurrence of the last search triggered from a source search
 # Do not localize "Cmd+Shift+G", or change the format of the string. These are
 # key identifiers, not messages displayed to the user.
 sourceSearch.search.againPrev.key3=Cmd+Shift+G
 
-# LOCALIZATION NOTE (sourceSearch.resultsSummary1): Shows a summary of
-# the number of matches for autocomplete
-sourceSearch.resultsSummary1=%d results
+# LOCALIZATION NOTE (sourceSearch.resultsSummary2): Semi-colon list of plural forms.
+# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
+# Shows a summary of the number of matches for autocomplete
+sourceSearch.resultsSummary2=#1 result;#1 results
 
 # LOCALIZATION NOTE (noMatchingStringsText): The text to display in the
 # global search results when there are no matching strings after filtering.
 noMatchingStringsText=No matches found
 
 # LOCALIZATION NOTE (emptySearchText): This is the text that appears in the
 # filter text box when it is empty and the scripts container is selected.
 emptySearchText=Search scripts (%S)
@@ -477,19 +478,20 @@ callStack.group.expandTooltip=Show %S fr
 # %S is replaced by the name of the library of the frames in the group.
 # example: `Collapse React frames`.
 callStack.group.collapseTooltip=Collapse %S frames
 
 # LOCALIZATION NOTE (components.header): Header for the
 # Framework Components pane in the right sidebar.
 components.header=Components
 
-# LOCALIZATION NOTE (editor.searchResults): Editor Search bar message
-# for the summarizing the selected search result. e.g. 5 of 10 results.
-editor.searchResults=%d of %d results
+# LOCALIZATION NOTE (editor.searchResults1): Semi-colon list of plural forms.
+# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
+# Editor Search bar message to summarize the selected search result. e.g. 5 of 10 results.
+editor.searchResults1=%d of #1 result;%d of #1 results
 
 # LOCALIZATION NOTE (editor.singleResult): Copy shown when there is one result.
 editor.singleResult=1 result
 
 # LOCALIZATION NOTE (editor.noResultsFound): Editor Search bar message
 # for when no results found.
 editor.noResultsFound=No results found
 
--- a/devtools/client/shared/build/build-debugger.js
+++ b/devtools/client/shared/build/build-debugger.js
@@ -66,16 +66,17 @@ const VENDORS = [
   "reselect",
   "whatwg-url",
   "Svg",
 ];
 
 const moduleMapping = {
   Telemetry: "devtools/client/shared/telemetry",
   asyncStorage: "devtools/shared/async-storage",
+  PluralForm: "devtools/shared/plural-form",
 };
 
 /*
  * Updates devtools-modules imports such as
  * `import { Telemetry } from "devtools-modules"`
  * so that we can customize how we resolve certain modules in the package
  *
  * In the case of multiple declarations we need to move
--- a/devtools/shared/plural-form.js
+++ b/devtools/shared/plural-form.js
@@ -193,10 +193,11 @@ const PluralForm = {
  */
 function log(aMsg)
 {
   let msg = "plural-form.js: " + (aMsg.join ? aMsg.join("") : aMsg);
   console.log(msg + "\n");
 }
 
 exports.PluralForm = PluralForm;
+exports.get = PluralForm.get;
 
 /* eslint-ensable */