adsys icon indicating copy to clipboard operation
adsys copied to clipboard

Unlocalized command line options

Open EduardGomezEscandell opened this issue 2 years ago • 4 comments

Description

i18n is initialized too late.

In adsysd/main.go and possibly all other main functions:

func main() {
    var a app
    switch filepath.Base(os.Args[0]) {
    case daemon.CmdName:
        a = daemon.New()   // In here we use i18n
    default:
        a = client.New()   // In here we use i18n
    }
    os.Exit(run(a))        // Here we initialize i18n
}

Nothing in the constructors is actually localized. So for instance --help will always show up in english.

Reproduction

I haven't tested it because I don't know how to build the project, I got this from static analysis when copying this project structure.

EduardGomezEscandell avatar Mar 29 '23 13:03 EduardGomezEscandell

This sure does look like a problem. But the fix should be as simple as moving a line. I'll open a PR for it real quick.

denisonbarbosa avatar Mar 29 '23 14:03 denisonbarbosa

Agreed, it's just moving the InitDomain to the main function.

We use this pattern in multiple repos (and even multiple places in some repose), so we should also consider where else this bug may exist.

EduardGomezEscandell avatar Mar 29 '23 14:03 EduardGomezEscandell

Is it still an issue in ADSys?

jibel avatar Nov 30 '23 13:11 jibel

Haven't manually checked. From reading the code, it would appear it still is an issue.

EduardGomezEscandell avatar Dec 11 '23 08:12 EduardGomezEscandell