Skip to content
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
14 changes: 14 additions & 0 deletions cmd/fyne/internal/commands/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ func initAction(ctx *cli.Context) error {
return fmt.Errorf("failed to run command: %v", err)
}

if err := os.Mkdir("translations", 0o755); err != nil {
return err
}

args := []string{ctx.App.Name, "translate"}
if verbose {
args = append(args, "-v")
}
args = append(args, "translations/en.json")
args = append(args, "main.go")
if err := ctx.App.Run(args); err != nil {
return fmt.Errorf("failed to run command: %v", err)
}

fmt.Println("Your new app is ready. Run it directly with: go run .")

return nil
Expand Down
7 changes: 4 additions & 3 deletions cmd/fyne/internal/mobile/binres/binres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,10 @@ func compareNamespaces(have, want *Namespace) error {
return nil
}

func rtou(a []TableRef) (b []uint32) {
for _, x := range a {
b = append(b, uint32(x))
func rtou(a []TableRef) []uint32 {
b := make([]uint32, len(a))
for i, x := range a {
b[i] = uint32(x)
}
return b
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/fyne/internal/mobile/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const (
minAndroidAPI = 15
)

func runBuild(cmd *command) (err error) {
_, err = runBuildImpl(cmd)
func runBuild(cmd *command) error {
_, err := runBuildImpl(cmd)
return err
}

Expand Down
13 changes: 12 additions & 1 deletion cmd/fyne/internal/templates/data/hello_world.got
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
package main

import (
"embed"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/lang"
"fyne.io/fyne/v2/widget"
)

//go:embed translations/*.json
var translationsFS embed.FS

func main() {
a := app.NewWithID({{ printf "%q" .Details.ID }})
w := a.NewWindow({{ printf "%q" .Details.Name }})

w.SetContent(widget.NewLabel("Hello World!"))
if err := lang.AddTranslationsFS(translationsFS, "translations"); err != nil {
fyne.LogError("failed to load translations", err)
}

w.SetContent(widget.NewLabel(lang.L("Hello World!")))
w.ShowAndRun()
}
Loading