internal/frontend,static: use singular nouns for search modes

The search modes are changed to the singular "package" and "identifier".
The constant values are also added to basePage, to ensure that the same
string is used throughout the templates and Go code.

For golang/go#47320
For golang/go#44142

Change-Id: Ia82f81b64fb267f4fe352359c0276426a69ebdaa
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/341178
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
diff --git a/internal/frontend/search.go b/internal/frontend/search.go
index 615b76a..1481819 100644
--- a/internal/frontend/search.go
+++ b/internal/frontend/search.go
@@ -253,11 +253,11 @@
 
 	// searchModePackage is the keyword prefix and query param for searching
 	// by packages.
-	searchModePackage = "packages"
+	searchModePackage = "package"
 
 	// searchModeSymbol is the keyword prefix and query param for searching
 	// by symbols.
-	searchModeSymbol = "identifiers"
+	searchModeSymbol = "identifier"
 )
 
 // serveSearch applies database data to the search template. Handles endpoint
diff --git a/internal/frontend/server.go b/internal/frontend/server.go
index 7e9a43c..8168be1 100644
--- a/internal/frontend/server.go
+++ b/internal/frontend/server.go
@@ -269,7 +269,16 @@
 	// layout base page is completed.
 	UseSiteWrapper bool
 
+	// SearchMode is the search mode for the current search request.
 	SearchMode string
+
+	// SearchModePackage is the value of const searchModePackage. It is used in
+	// the search bar dropdown.
+	SearchModePackage string
+
+	// SearchModeSymbol is the value of const searchModeSymbol. It is used in
+	// the search bar dropdown.
+	SearchModeSymbol string
 }
 
 // licensePolicyPage is used to generate the static license policy page.
@@ -301,7 +310,9 @@
 		DevMode:            s.devMode,
 		AppVersionLabel:    s.appVersionLabel,
 		GoogleTagManagerID: s.googleTagManagerID,
-		SearchMode:         "packages",
+		SearchMode:         searchModePackage,
+		SearchModePackage:  searchModePackage,
+		SearchModeSymbol:   searchModeSymbol,
 	}
 }
 
diff --git a/static/frontend/search/search.tmpl b/static/frontend/search/search.tmpl
index 4322d0c..d2f6d23 100644
--- a/static/frontend/search/search.tmpl
+++ b/static/frontend/search/search.tmpl
@@ -15,7 +15,7 @@
 {{define "main"}}
   <main class="go-Container">
     <div class="go-Content SearchResults">
-      {{if eq .SearchMode "identifiers"}}
+      {{if eq .SearchMode .SearchModeSymbol }}
         {{template "search_identifier" .}}
       {{else}}
         {{template "search_package" .}}
@@ -29,9 +29,8 @@
 
 {{define "search_identifier"}}
   <h1>Identifiers matching “{{.Query}}”</h1>
-  <a class="SearchResults-instead" href="{{.Pagination.URL .Pagination.Limit "packages" .Query}}">
-    <span>Search instead for </span>
-    “package: {{.Query}}”
+  <a class="SearchResults-instead" href="{{.Pagination.URL .Pagination.Limit .SearchModePackage .Query}}">
+    <span>Search instead for </span>“{{.SearchModePackage}}: {{.Query}}”
   </a>
   {{if gt (len .Results) 0}}
     <div class="SearchResults-summary">
@@ -82,9 +81,8 @@
 
 {{define "search_package"}}
   <h1>Search results for “{{.Query}}”</h1>
-  <a class="SearchResults-instead" href="{{.Pagination.URL .Pagination.Limit "identifiers" .Query}}">
-    <span class="SearchSnippet-symbolPackagePath">Search instead for </span>
-    “identifier: {{.Query}}”
+  <a class="SearchResults-instead" href="{{.Pagination.URL .Pagination.Limit .SearchModeSymbol .Query}}">
+    <span class="SearchSnippet-symbolPackagePath">Search instead for </span>“{{.SearchModeSymbol}}: {{.Query}}”
   </a>
   {{if gt (len .Results) 0}}
     <div class="SearchResults-summary">
diff --git a/static/shared/header/header.tmpl b/static/shared/header/header.tmpl
index 9a612b7..e23bf39 100644
--- a/static/shared/header/header.tmpl
+++ b/static/shared/header/header.tmpl
@@ -80,8 +80,8 @@
   >
     {{if .Experiments.IsActive "symbol-search"}}
       <select name="m" class="go-Select js-searchModeSelect">
-        <option value="packages">Packages</option>
-        <option {{if eq .SearchMode "identifiers"}}selected{{end}} value="identifiers">Identifiers</option>
+        <option value="{{.SearchModePackage}}">Packages</option>
+        <option {{if eq .SearchMode .SearchModeSymbol}}selected{{end}} value="{{.SearchModeSymbol}}">Identifiers</option>
       </select>
     {{end}}
     <input name="q" class="go-Input js-searchFocus" aria-label="Search for a package" type="search"