Skip to content

Commit

Permalink
internal/middleware: delete Language and languageTag
Browse files Browse the repository at this point in the history
The Language middleware isn't referenced anywhere else in the code, so
the context tag can't be set anywhere and languageTag must always be
returning English. Just hardcode English everywhere instead

For golang/go#61399

Change-Id: Id8cee6b9fb87a7f8f3460fb6eaf2f14ea0af7c8d
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/514675
Run-TryBot: Michael Matloob <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
kokoro-CI: kokoro <[email protected]>
Reviewed-by: Jamal Carvalho <[email protected]>
  • Loading branch information
matloob committed Aug 4, 2023
1 parent 9e6bdc9 commit b486dfa
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 40 deletions.
4 changes: 2 additions & 2 deletions internal/frontend/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

"golang.org/x/pkgsite/internal"
"golang.org/x/pkgsite/internal/log"
"golang.org/x/pkgsite/internal/middleware"
"golang.org/x/pkgsite/internal/stdlib"
"golang.org/x/text/language"
"golang.org/x/text/message"
)

Expand Down Expand Up @@ -125,7 +125,7 @@ func fetchImportedByDetails(ctx context.Context, ds internal.DataSource, pkgPath
// Display the number of importers, taking into account the number we
// actually retrieved, the limit on that number, and the imported-by count
// in the search_documents table.
pr := message.NewPrinter(middleware.LanguageTag(ctx))
pr := message.NewPrinter(language.English)
var (
display string
pkgword = "package"
Expand Down
4 changes: 2 additions & 2 deletions internal/frontend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
"golang.org/x/pkgsite/internal/godoc"
"golang.org/x/pkgsite/internal/godoc/dochtml"
"golang.org/x/pkgsite/internal/log"
"golang.org/x/pkgsite/internal/middleware"
"golang.org/x/pkgsite/internal/middleware/stats"
"golang.org/x/pkgsite/internal/version"
"golang.org/x/text/language"
"golang.org/x/text/message"
)

Expand Down Expand Up @@ -196,7 +196,7 @@ func fetchMainDetails(ctx context.Context, ds internal.DataSource, um *internal.
}
isTaggedVersion := versionType != version.TypePseudo
isStableVersion := semver.Major(um.Version) != "v0" && versionType == version.TypeRelease
pr := message.NewPrinter(middleware.LanguageTag(ctx))
pr := message.NewPrinter(language.English)
return &MainDetails{
ExpandReadme: expandReadme,
Directories: unitDirectories(append(subdirectories, nestedModules...)),
Expand Down
4 changes: 2 additions & 2 deletions internal/frontend/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
"golang.org/x/pkgsite/internal"
"golang.org/x/pkgsite/internal/derrors"
"golang.org/x/pkgsite/internal/log"
"golang.org/x/pkgsite/internal/middleware"
"golang.org/x/pkgsite/internal/stdlib"
"golang.org/x/pkgsite/internal/version"
"golang.org/x/pkgsite/internal/vuln"
"golang.org/x/text/language"
"golang.org/x/text/message"
)

Expand Down Expand Up @@ -254,7 +254,7 @@ func fetchSearchPage(ctx context.Context, ds internal.DataSource, cq, symbol str

var results []*SearchResult
for _, r := range dbresults {
sr := newSearchResult(r, searchSymbols, message.NewPrinter(middleware.LanguageTag(ctx)))
sr := newSearchResult(r, searchSymbols, message.NewPrinter(language.English))
results = append(results, sr)
}

Expand Down
34 changes: 0 additions & 34 deletions internal/middleware/language.go

This file was deleted.

0 comments on commit b486dfa

Please sign in to comment.