diff --git a/cmd/fyne/internal/commands/package-darwin.go b/cmd/fyne/internal/commands/package-darwin.go index 4b259e202a..5cf3feb55a 100644 --- a/cmd/fyne/internal/commands/package-darwin.go +++ b/cmd/fyne/internal/commands/package-darwin.go @@ -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) @@ -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) } diff --git a/cmd/fyne/internal/commands/package-darwin_test.go b/cmd/fyne/internal/commands/package-darwin_test.go new file mode 100644 index 0000000000..97896ae053 --- /dev/null +++ b/cmd/fyne/internal/commands/package-darwin_test.go @@ -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]) +}