feat(i18n): integrate i18next for internationalization support and add initial translation setup
This commit is contained in:
@@ -9,7 +9,9 @@ import (
|
||||
"equipment-analyzer/internal/utils"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -237,6 +239,9 @@ func (ps *ParserService) convertGear(item map[string]interface{}) {
|
||||
if _, exists := item["type"]; !exists {
|
||||
if code, exists := item["code"].(string); exists {
|
||||
baseCode := code
|
||||
if parts := strings.Split(code, "_"); len(parts) > 0 {
|
||||
baseCode = parts[0]
|
||||
}
|
||||
if idx := len(baseCode) - 1; idx >= 0 {
|
||||
gearLetter := string(baseCode[idx])
|
||||
item["gear"] = gearByGearLetter[gearLetter]
|
||||
@@ -324,7 +329,7 @@ func (ps *ParserService) convertMainStat(item map[string]interface{}) {
|
||||
if ps.isFlat(mainOpType) {
|
||||
mainValue = mainStatValue
|
||||
} else {
|
||||
mainValue = mainStatValue * 100
|
||||
mainValue = ps.round10ths(mainStatValue * 100)
|
||||
}
|
||||
|
||||
if mainValue == 0 || mainValue != mainValue { // NaN check
|
||||
@@ -367,7 +372,7 @@ func (ps *ParserService) convertSubStats(item map[string]interface{}) {
|
||||
if ps.isFlat(opType) {
|
||||
value = opValue
|
||||
} else {
|
||||
value = opValue * 100
|
||||
value = ps.round10ths(opValue * 100)
|
||||
}
|
||||
|
||||
if existingStat, exists := statAcc[statType]; exists {
|
||||
@@ -428,6 +433,10 @@ func (ps *ParserService) isFlat(text string) bool {
|
||||
return text == "max_hp" || text == "speed" || text == "att" || text == "def"
|
||||
}
|
||||
|
||||
func (ps *ParserService) round10ths(value float64) float64 {
|
||||
return math.Round(value*10) / 10
|
||||
}
|
||||
|
||||
// 映射常量
|
||||
var (
|
||||
rankByIngameGrade = []string{
|
||||
@@ -476,6 +485,10 @@ var (
|
||||
"set_vampire": "LifestealSet",
|
||||
"set_shield": "ProtectionSet",
|
||||
"set_torrent": "TorrentSet",
|
||||
"set_revenant": "ReversalSet",
|
||||
"set_riposte": "RiposteSet",
|
||||
"set_chase": "PursuitSet",
|
||||
"set_opener": "WarfareSet",
|
||||
}
|
||||
|
||||
statByIngameStat = map[string]string{
|
||||
|
||||
Reference in New Issue
Block a user