golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.27k stars 17.7k forks source link

x/text/unicode/cldr: Decoder fails to load cldr-common-41.0.zip #53016

Open dolmen opened 2 years ago

dolmen commented 2 years ago

What version of Go are you using (go version)?

$ go version
go version go1.18.2 darwin/amd64
$ go list -m golang.org/x/text
golang.org/x/text v0.3.7

Does this issue reproduce with the latest release?

Yes. golang.org/x/text v0.3.7

What did you do?

Using the latest CLDR release v41.0: http://unicode.org/Public/cldr/41/cldr-common-41.0.zip

    zip, err := os.Open(cldrArchivePath)
    if err != nil {
        log.Fatalf("%s: %s", cldrArchivePath, err)
    }

    cldrDecoder := &cldr.Decoder{}
    log.Println("Loading...")
    db, err := cldrDecoder.DecodeZip(zip)
    if err != nil {
        log.Fatalf("%s: %s", cldrArchivePath, err)
    }
    log.Println("success.")

Full code: https://github.com/blueboardio/cldr/blob/master/currency/currencies_gen.go#L73

What did you expect to see?

success.

(like with cldr-common-40.0.zip)

What did you see instead?

cldr-common-41.0.zip: supplemental-temp/coverageLevels2: missing identity element

mknyszek commented 2 years ago

CC @mpvl also.

neild commented 2 years ago

I attempted to fix this, and spent rather more time learning about CLDR than I intended. Documenting what I found so far:

dolmen commented 1 year ago

Still happens with latest code (golang.org/x/text v0.6.0) and data (cldr-common-42.0.zip).

dolmen commented 1 year ago

I found a workaround for my use case: use a DirFilter:

cldrDecoder.SetDirFilter("main", "supplemental")