diff --git a/cmd/translate/gen-id.go b/cmd/translate/gen-id.go index 3972175..a4c1622 100644 --- a/cmd/translate/gen-id.go +++ b/cmd/translate/gen-id.go @@ -1,8 +1,7 @@ package main import ( - "hash/crc64" - "io" + "hash/crc32" "os" "github.com/pelletier/go-toml/v2" @@ -28,17 +27,8 @@ func genIDCmd(c *cli.Context) error { } fl.Close() - hash := crc64.New(crc64.MakeTable(crc64.ISO)) - for i, item := range tr.Items { - hash.Reset() - - _, err := io.WriteString(hash, item.Value) - if err != nil { - return err - } - - tr.Items[i].ID = hash.Sum64() + tr.Items[i].ID = crc32.ChecksumIEEE([]byte(item.Value)) } fl, err = os.Create(c.Args().First()) diff --git a/translate.go b/translate.go index d1b6a42..c7e733b 100644 --- a/translate.go +++ b/translate.go @@ -1,8 +1,7 @@ package translate import ( - "hash/crc64" - "io" + "hash/crc32" "io/fs" "os" "path/filepath" @@ -17,11 +16,11 @@ type Translations struct { } type Translation struct { - ID uint64 `toml:"id"` + ID uint32 `toml:"id"` Value string `toml:"value"` } -type Dictionary map[uint64]string +type Dictionary map[uint32]string type Catalog map[language.Tag]Dictionary type Translator struct { @@ -107,11 +106,6 @@ func toDict(tr Translations) Dictionary { return out } -func hashString(s string) uint64 { - hash := crc64.New(crc64.MakeTable(crc64.ISO)) - _, err := io.WriteString(hash, s) - if err != nil { - return 0 - } - return hash.Sum64() +func hashString(s string) uint32 { + return crc32.ChecksumIEEE([]byte(s)) }