fix: sync env config (#319)

This commit is contained in:
Lykin 2024-08-06 18:12:21 +08:00
parent 0038092193
commit b26f5d2bde
2 changed files with 17 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import (
"github.com/adrg/sysfont"
runtime2 "github.com/wailsapp/wails/v2/pkg/runtime"
"net/http"
"os"
"sort"
"strings"
"sync"
@ -50,6 +51,7 @@ func (p *preferencesService) SetPreferences(pf types.Preferences) (resp types.JS
return
}
p.UpdateEnv()
resp.Success = true
return
}
@ -114,6 +116,11 @@ func (p *preferencesService) GetBuildInDecoder() (resp types.JSResp) {
return
}
func (p *preferencesService) GetLanguage() string {
pref := p.pref.GetPreferences()
return pref.General.Language
}
func (p *preferencesService) SetAppVersion(ver string) {
if !strings.HasPrefix(ver, "v") {
p.clientVersion = "v" + ver
@ -246,3 +253,12 @@ func (p *preferencesService) CheckForUpdate() (resp types.JSResp) {
}
return
}
// UpdateEnv Update System Environment
func (p *preferencesService) UpdateEnv() {
if p.GetLanguage() == "zh" {
os.Setenv("LANG", "zh_CN.UTF-8")
} else {
os.Unsetenv("LANG")
}
}

View File

@ -35,6 +35,7 @@ func main() {
pubsubSvc := services.Pubsub()
prefSvc := services.Preferences()
prefSvc.SetAppVersion(version)
prefSvc.UpdateEnv()
windowWidth, windowHeight, maximised := prefSvc.GetWindowSize()
windowStartState := options.Normal
if maximised {