mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Add support for user-configuration language tag specification. (#1038)
Adds a new top-level configuration key called "language": ```yaml wtf: langauge: "ja-JP" ``` Users can now define which BCP 47 language tag to use to format any text or numbers that currently support localization. Defaults to "en-CA". Acceptible values: any BCP 47 language tag recognized by the Go "language" package. Good luck to you figuring out what that cannonical list is. After a morning of trying to suss it out, I have no idea. Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
@@ -4,8 +4,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
ghb "github.com/google/go-github/v32/github"
|
||||
"golang.org/x/text/language"
|
||||
"golang.org/x/text/message"
|
||||
)
|
||||
|
||||
func (widget *Widget) display() {
|
||||
@@ -124,13 +122,16 @@ func (widget *Widget) displayMyReviewRequests(repo *Repo, username string) strin
|
||||
}
|
||||
|
||||
func (widget *Widget) displayStats(repo *Repo) string {
|
||||
prntr := message.NewPrinter(language.English)
|
||||
locPrinter, err := widget.settings.LocalizedPrinter()
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
str := fmt.Sprintf(
|
||||
" PRs: %s Issues: %s Stars: %s\n",
|
||||
prntr.Sprintf("%d", repo.PullRequestCount()),
|
||||
prntr.Sprintf("%d", repo.IssueCount()),
|
||||
prntr.Sprintf("%d", repo.StarCount()),
|
||||
locPrinter.Sprintf("%d", repo.PullRequestCount()),
|
||||
locPrinter.Sprintf("%d", repo.IssueCount()),
|
||||
locPrinter.Sprintf("%d", repo.StarCount()),
|
||||
)
|
||||
|
||||
return str
|
||||
|
||||
@@ -105,12 +105,14 @@ func (widget *Widget) content() (string, string, bool) {
|
||||
}
|
||||
var str string
|
||||
|
||||
locPrinter, _ := widget.settings.LocalizedPrinter()
|
||||
|
||||
for idx, stream := range widget.topStreams {
|
||||
row := fmt.Sprintf(
|
||||
"[%s]%2d. [red]%s [white]%s",
|
||||
widget.RowColor(idx),
|
||||
idx+1,
|
||||
utils.PrettyNumber(float64(stream.ViewerCount)),
|
||||
utils.PrettyNumber(locPrinter, float64(stream.ViewerCount)),
|
||||
stream.Streamer,
|
||||
)
|
||||
str += utils.HighlightableHelper(widget.View, row, idx, len(stream.Streamer))
|
||||
|
||||
Reference in New Issue
Block a user