Skip to content

Commit

Permalink
v0.0.7 - 优化英文输出
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritLHLS committed Jul 4, 2024
1 parent 2bcc70a commit 5b900f6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
TAG="v0.0.6-$(date +'%Y%m%d%H%M%S')"
TAG="v0.0.7-$(date +'%Y%m%d%H%M%S')"
git tag $TAG
git push origin $TAG
env:
Expand Down
6 changes: 3 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,22 @@ func main() {
}
if strings.ToLower(testMethod) == "origin" {
if url != "" && parseType != "" {
sp.CustomSpeedTest(url, parseType, num)
sp.CustomSpeedTest(url, parseType, num, language)
} else {
fmt.Println("-opt/-pf with wrong operator.")
}
} else if strings.ToLower(testMethod) == "speedtest" {
err := sp.OfficialAvailableTest()
if err == nil {
if url != "" && parseType != "" {
sp.OfficialCustomSpeedTest(url, parseType, num)
sp.OfficialCustomSpeedTest(url, parseType, num, language)
} else {
fmt.Println("-opt/-pf with wrong operator.")
}
} else {
fmt.Println("Can not match speedtest command, switch to use origin test")
if url != "" && parseType != "" {
sp.CustomSpeedTest(url, parseType, num)
sp.CustomSpeedTest(url, parseType, num, language)
} else {
fmt.Println("-opt/-pf with wrong operator.")
}
Expand Down
2 changes: 1 addition & 1 deletion model/model.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package model

const SpeedTestVersion = "v0.0.6"
const SpeedTestVersion = "v0.0.7"

var EnableLoger = false
var (
Expand Down
28 changes: 24 additions & 4 deletions sp/sp.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func OfficialNearbySpeedTest() {
}
}

func OfficialCustomSpeedTest(url, byWhat string, num int) {
func OfficialCustomSpeedTest(url, byWhat string, num int, language string) {
if model.EnableLoger {
InitLogger()
defer Logger.Sync()
Expand Down Expand Up @@ -129,7 +129,17 @@ func OfficialCustomSpeedTest(url, byWhat string, num int) {
}
}
if Latency != "" && DLStr != "" && UPStr != "" && PacketLoss != "" {
fmt.Print(formatString(serverName, 16))
if language == "zh" {
fmt.Print(formatString(serverName, 16))
} else if language == "en" {
name := serverName
name = strings.ReplaceAll(name, "中国香港", "HongKong")
name = strings.ReplaceAll(name, "洛杉矶", "LosAngeles")
name = strings.ReplaceAll(name, "日本东京", "Tokyo,Japan")
name = strings.ReplaceAll(name, "新加坡", "Singapore")
name = strings.ReplaceAll(name, "法兰克福", "Frankfurt")
fmt.Print(formatString(name, 16))
}
fmt.Print(formatString(UPStr, 16))
fmt.Print(formatString(DLStr, 16))
fmt.Print(formatString(Latency, 16))
Expand Down Expand Up @@ -182,7 +192,7 @@ func NearbySpeedTest() {
}
}

func CustomSpeedTest(url, byWhat string, num int) {
func CustomSpeedTest(url, byWhat string, num int, language string) {
if model.EnableLoger {
InitLogger()
defer Logger.Sync()
Expand Down Expand Up @@ -253,7 +263,17 @@ func CustomSpeedTest(url, byWhat string, num int) {
server.Context.Reset()
continue
}
fmt.Print(formatString(server.Name, 16))
if language == "zh" {
fmt.Print(formatString(server.Name, 16))
} else if language == "en" {
name := server.Name
name = strings.ReplaceAll(name, "中国香港", "HongKong")
name = strings.ReplaceAll(name, "洛杉矶", "LosAngeles")
name = strings.ReplaceAll(name, "日本东京", "Tokyo,Japan")
name = strings.ReplaceAll(name, "新加坡", "Singapore")
name = strings.ReplaceAll(name, "法兰克福", "Frankfurt")
fmt.Print(formatString(name, 16))
}
fmt.Print(formatString(fmt.Sprintf("%-8s", fmt.Sprintf("%.2f", server.ULSpeed.Mbps())+" Mbps"), 16))
fmt.Print(formatString(fmt.Sprintf("%-8s", fmt.Sprintf("%.2f", server.DLSpeed.Mbps())+" Mbps"), 16))
fmt.Print(formatString(fmt.Sprintf("%s", server.Latency), 16))
Expand Down

0 comments on commit 5b900f6

Please sign in to comment.