fix bug:raw和classic模式增加语言个性化输出

注意:classic模式将会被废弃,请不要在此模式基础上开发
This commit is contained in:
tsosunchia
2023-05-25 20:40:12 +08:00
parent 6bc74e14cb
commit b622a40022
4 changed files with 48 additions and 25 deletions

View File

@@ -2,6 +2,7 @@ package printer
import (
"fmt"
"github.com/xgadget-lab/nexttrace/trace"
"net"
"github.com/fatih/color"
@@ -70,3 +71,30 @@ func PrintTraceRouteNav(ip net.IP, domain string, dataOrigin string, maxHops int
fmt.Printf("traceroute to %s (%s), %d hops max, 32 byte packets\n", ip.String(), domain, maxHops)
}
}
func applyLangSetting(h *trace.Hop) {
if len(h.Geo.Country) <= 1 {
h.Geo.Country = "局域网"
h.Geo.CountryEn = "LAN Address"
}
if h.Lang == "en" {
if h.Geo.Country == "Anycast" {
} else if h.Geo.Prov == "骨干网" {
h.Geo.Prov = "BackBone"
} else if h.Geo.ProvEn == "" {
h.Geo.Country = h.Geo.CountryEn
} else {
if h.Geo.CityEn == "" {
h.Geo.Country = h.Geo.ProvEn
h.Geo.Prov = h.Geo.CountryEn
h.Geo.City = ""
} else {
h.Geo.Country = h.Geo.CityEn
h.Geo.Prov = h.Geo.ProvEn
h.Geo.City = h.Geo.CountryEn
}
}
}
}