Skip to content

Commit

Permalink
Make sure to pass underscore as separator
Browse files Browse the repository at this point in the history
  • Loading branch information
sdassow committed Nov 20, 2024
1 parent f1198f2 commit ee8fc8a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/fyne/internal/commands/package-darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ type darwinData struct {
Languages []string
}

func darwinLangs(langs []string) []string {
r := make([]string, len(langs))
for n, lang := range langs {
r[n] = strings.Replace(lang, "-", "_", 1)
}
return r
}

func (p *Packager) packageDarwin() (err error) {
appDir := util.EnsureSubDir(p.dir, p.Name+".app")
exeName := filepath.Base(p.exe)
Expand All @@ -41,7 +49,7 @@ func (p *Packager) packageDarwin() (err error) {
}()

tplData := darwinData{Name: p.Name, ExeName: exeName, AppID: p.AppID, Version: p.AppVersion, Build: p.AppBuild,
Category: strings.ToLower(p.category), Languages: p.langs}
Category: strings.ToLower(p.category), Languages: darwinLangs(p.langs)}
if err := templates.InfoPlistDarwin.Execute(infoFile, tplData); err != nil {
return fmt.Errorf("failed to write plist template: %w", err)
}
Expand Down
15 changes: 15 additions & 0 deletions cmd/fyne/internal/commands/package-darwin_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package commands

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestDarwinLangs(t *testing.T) {
langs := darwinLangs([]string{"en-GB", "de-CH"})

assert.Equal(t, 2, len(langs))
assert.Equal(t, "en_GB", langs[0])
assert.Equal(t, "de_CH", langs[1])
}

0 comments on commit ee8fc8a

Please sign in to comment.