From ee8fc8a0948607ca3cecf2e096a9f38bfdb7e003 Mon Sep 17 00:00:00 2001 From: Simon Dassow Date: Wed, 20 Nov 2024 18:06:35 +0100 Subject: [PATCH] Make sure to pass underscore as separator --- cmd/fyne/internal/commands/package-darwin.go | 10 +++++++++- cmd/fyne/internal/commands/package-darwin_test.go | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 cmd/fyne/internal/commands/package-darwin_test.go 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]) +}