go-playground / locales

:earth_americas: a set of locales generated from the CLDR Project which can be used independently or within an i18n package; these were built for use with, but not exclusive to https://github.com/go-playground/universal-translator
MIT License
268 stars 55 forks source link

Index out of range (decimal, group, minus..) #5

Closed dvorakluk closed 7 years ago

dvorakluk commented 7 years ago

First, let me thank you for this beautiful package.

I think there is missing check for the length of decimal, group and minus fields used for number formatting, as I'm getting runtime error: index out of range with locales/cs.(*cs).FmtCurrency

If these are not available in the cldr data, locales package should not panic.

But if I look into the cldr, i see them there (for cs.xml), so there probably some problem with parsing them? Have you opensourced the parser/generator?

deankarn commented 7 years ago

Hey @dvorakluk

Thanks yes the parser is open-sourced... just a little hidden https://github.com/go-playground/locales/tree/master/cmd not on purpose, but just gets lost in all the folders.

just a heads up the code is more to get it generated and is not very refined yet (wanted to wait until there were tests for all languages before refining)

I do leverage https://godoc.org/golang.org/x/text/unicode/cldr heavily to do the initial XML loading.

I left some things to panic because if the information isn't there, then that locale shouldn't be used and didn't want to give someone a false sense that it was working, when in fact the data to do so is missing; but if the info is there, there very well may be a problem.

is there a specific locale? cs, cs_...?

I welcome any help you could provide 😄

dvorakluk commented 7 years ago

My fault, I have overlooked it in the bunch of folders :) Please take a look at the PR, it should parse the info where available and thus resolve this issue.

deankarn commented 7 years ago

I will take a look later tonight as soon as I get the chance

deankarn commented 7 years ago

changes merged & locales regenerated in v0.10.3

Thanks @dvorakluk I cannot express what a help this is 👍 Thank You!