Skip to content

Commit

Permalink
fix: sync env config (tiny-craft#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiny-craft committed Aug 6, 2024
1 parent 0038092 commit b26f5d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions backend/services/preferences_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/adrg/sysfont"
runtime2 "github.com/wailsapp/wails/v2/pkg/runtime"
"net/http"
"os"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -50,6 +51,7 @@ func (p *preferencesService) SetPreferences(pf types.Preferences) (resp types.JS
return
}

p.UpdateEnv()
resp.Success = true
return
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
}
}
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b26f5d2

Please sign in to comment.