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

Unit Formatter Returning Internal Error with CLDR v40.0.0 #929

Open
ritikmmathur opened this issue Apr 6, 2022 · 5 comments · May be fixed by microsoft/BotFramework-WebChat#4874
Open

Comments

@ritikmmathur
Copy link

ritikmmathur commented Apr 6, 2022

Hi All,

For locale, es when i am using unitformatter, i am getting internal error.

Sample usage:

globalize.unitFormatter("bestFit", {
      form: "narrow"
    }).format(value)

Error Stack Trace:

Error: Oops, internal error
  e is not defined
  ReferenceError: e is not defined
      at eval (eval at buildFunction (node_modules/globalize/dist/globalize/plural.js:227:20), <anonymous>:2:3)
      at pluralGenerator (node_modules/globalize/dist/globalize/plural.js:297:10)
      at unitFormat (node_modules/globalize/dist/globalize/unit.js:74:16)
      at formatter (node_modules/globalize/dist/globalize/unit.js:101:10)

In CLDR v27.0.0, plural.json has following data,

"es": {
        "pluralRule-count-one": "n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000",
        "pluralRule-count-other": " @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …"
      }

where as in v40.0.0 plural.json has following data:

"es": {
        "pluralRule-count-one": "n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000",
        "pluralRule-count-many": "e = 0 and i != 0 and i % 1000000 = 0 and v = 0 or e != 0..5 @integer 1000000, 1c6, 2c6, 3c6, 4c6, 5c6, 6c6, … @decimal 1.0000001c6, 1.1c6, 2.0000001c6, 2.1c6, 3.0000001c6, 3.1c6, …",
        "pluralRule-count-other": " @integer 0, 2~16, 100, 1000, 10000, 100000, 1c3, 2c3, 3c3, 4c3, 5c3, 6c3, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, 1.0001c3, 1.1c3, 2.0001c3, 2.1c3, 3.0001c3, 3.1c3, …"
      }

Note: for key pluralRule-count-many value has e

Similar error is returned for fr locale.

Please suggest a way to resolve this issue. Also, I would be happy to inner-source the fix 😄

Thanks,

Ritika

@rxaviers
Copy link
Member

rxaviers commented Apr 7, 2022

Hi @ritikmmathur!

I believe e isn't supported by the version of messageformat we're using under the hoods in globalize. I suggest: (a) checking if latest messageformat supports it, and in case it does (b) bumping up the dependency here --- that's easier said than done since globalize doesn't simply use npm dependency, but a custom way to embed it.

In the meantime, some observations. The e pattern is a deprecated synonym for ‘c’. which in turn is compact decimal exponent value: exponent of the power of 10 used in compact decimal formatting according to https://www.unicode.org/reports/tr35/tr35-numbers.html#Plural_Operand_Meanings. In case plural isn't being used for such case, I believe it's possible to strip this data out from your CLDR usage safely and have globalize working just fine.

@rxaviers
Copy link
Member

rxaviers commented Apr 7, 2022

I'd happily accept a PR in case you choose the update above (or any other solution). Thanks

@ritikmmathur
Copy link
Author

ritikmmathur commented Apr 8, 2022

globalize has dependency on make-plural package. In latest version i see they have added support to handle e pattern code link. After doing initial testing, unit formatter is working with make-plural version make-plural-cli@7.1.0.

Would it be okay if I raise PR to update make-plural dependency ??

@rxaviers
Copy link
Member

Sure and thanks!

@fatso83
Copy link

fatso83 commented Oct 16, 2022

@ritikmmathur Where's the corresponding PR? Tried searching the pull requests for your username and came up empty.

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

Successfully merging a pull request may close this issue.

3 participants