fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25.22k stars 1.4k forks source link

Error parsing user locale #5271

Closed rahji closed 6 days ago

rahji commented 1 week ago

Checklist

Describe the bug

When running any Fyne application (eg: setup or the fyne demo or the hello world code) I get the following errors on the console before the app appears:

2024/11/17 12:31:56 Fyne error:  Error parsing user locale
2024/11/17 12:31:56   Cause: language: tag is not well-formed
2024/11/17 12:31:56   At: /home/robduarte/go/pkg/mod/fyne.io/fyne/v2@v2.5.2/lang/locale.go:35
2024/11/17 12:31:57 Fyne error:  Error parsing user locale
2024/11/17 12:31:57   Cause: language: tag is not well-formed
2024/11/17 12:31:57   At: /home/robduarte/go/pkg/mod/fyne.io/fyne/v2@v2.5.2/lang/locale.go:23

The application does open and I don't see any other problems. I am using WSL2 on Windows.

The error goes away after setting the locale with LANG=en_US.UTF-8. I'm not sure why the locale isn't set but I expect others will experience the same problem if they're using WSL2?

Also strange: if I subsequently set LANG= the error still doesn't appear.

How to reproduce

  1. start any Fyne app on WSL2 (where LANG hasn't been explicitly set)

Screenshots

No response

Example code

Any code has the same effect but here is the hello world:

package main

import (
        "fyne.io/fyne/v2/app"
        "fyne.io/fyne/v2/widget"
)

func main() {
        a := app.New()
        w := a.NewWindow("Hello World")

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

Fyne version

2.5.2

Go compiler version

1.23.3

Operating system and version

Windows 11, WSL2 Linux CFA-L-F888JR3 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Additional Information

No response

andydotxyz commented 1 week ago

I cannot replicate this on WSL at all. The LANG is correctly set. And even if it is blank the errors do not appear.

The only way I can get it to appear is if I LANG=x go run main.go - can you please confirm what echo $LANG says for your default setup?

rahji commented 1 week ago

Sorry, I find the same as you now. If I unset it, it doesn't create the error. If I set it to an invalid LANG it does show the error. Perhaps it would be helpful to show the language in the error instead of simply "Cause: language: tag is not well-formed At: /home/robduarte/go/pkg/mod/fyne.io/fyne/v2@v2.5.2/lang/locale.go:35" - that way if this crops up again, there will be some clues?

andydotxyz commented 6 days ago

Thanks, updated accordingly