Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add languages to metadata and use for language integration in macOS #5279

Merged
merged 5 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cmd/fyne/internal/commands/package-darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ type darwinData struct {
Version string
Build int
Category string
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) {
Expand All @@ -40,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)}
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])
}
2 changes: 2 additions & 0 deletions cmd/fyne/internal/commands/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ type Packager struct {
certificate, profile string // optional flags for releasing
tags, category string
tempDir string
langs []string

customMetadata keyValueFlag
linuxAndBSDMetadata *metadata.LinuxAndBSD
Expand Down Expand Up @@ -344,6 +345,7 @@ func (p *Packager) validate() (err error) {

p.appData.mergeMetadata(data)
p.sourceMetadata = data.Source
p.langs = data.Languages

p.linuxAndBSDMetadata = data.LinuxAndBSD
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/fyne/internal/templates/bundled.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion cmd/fyne/internal/templates/data/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
{{- if .Languages}}
<key>CFBundleLocalizations</key>
<array>
{{- range .Languages}}
<string>{{.}}</string>
{{- end}}
</array>
{{- end}}
<key>LSApplicationCategoryType</key>
<string>public.app-category.{{.Category}}</string>
<key>LSMinimumSystemVersion</key>
<string>10.11</string>
</dict>
</plist>
</plist>
1 change: 1 addition & 0 deletions internal/metadata/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type FyneApp struct {
Release map[string]string `toml:",omitempty"`
Source *AppSource `toml:",omitempty"`
LinuxAndBSD *LinuxAndBSD `toml:",omitempty"`
Languages []string `toml:",omitempty"`
}

// AppDetails describes the build information, this group may be OS or arch specific
Expand Down