Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unitFormatter throw exception for locale "pl" with cldr-data 35 #934

Closed
LilyLi2019 opened this issue Nov 3, 2022 · 3 comments
Closed

unitFormatter throw exception for locale "pl" with cldr-data 35 #934

LilyLi2019 opened this issue Nov 3, 2022 · 3 comments

Comments

@LilyLi2019
Copy link

var formatter = Globalize("pl-PL").unitFormatter( 'digital-petabyte', { form: 'long' } );
console.log(formatter( 2 ));

It throws exceptions:
PS C:\LilyLi\VMC\devCode\testCode> node .\test.ts
C:\LilyLi\VMC\devCode\testCode\node_modules\globalize\dist\globalize.js:73
message = message.replace( /{[0-9a-zA-Z-_. ]+}/g, function( name ) {
^

TypeError: Cannot read property 'replace' of undefined
at formatMessage (C:\LilyLi\VMC\devCode\testCode\node_modules\globalize\dist\globalize.js:73:20)
at unitFormat (C:\LilyLi\VMC\devCode\testCode\node_modules\globalize\dist\globalize\unit.js:89:9)
at unitFormatter (C:\LilyLi\VMC\devCode\testCode\node_modules\globalize\dist\globalize\unit.js:100:10)
at Object. (C:\LilyLi\VMC\devCode\testCode\test.ts:143:13)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47

Please note:
It works good with cldr-data version 34.
But it failed with above exception with cldr-data version 35, 36.

@rxaviers
Copy link
Member

rxaviers commented Nov 3, 2022

Thank you for filing the issue. Please, is it a dup of #932? I see the new data has additional forms (link) compared to v34 (link). We need to figure out what's missing from the data that the current code considers present but is undefined. We may also want to check updated specs https://www.unicode.org/reports/tr35/tr35-numbers.html so that code updates match specs.

I am open for PR fixing it.

@LilyLi2019
Copy link
Author

Thanks @rxaviers for checking this issue.
Yes, it is a dup of #932. Sorry I did not search existing issue carefully.
I will close this one and track the fix on #932.

@rxaviers
Copy link
Member

rxaviers commented Nov 4, 2022

No problem and thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants