globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 602 forks source link

version upgrade to 1.1.0 Uncaught Error: E_MISSING_CLDR #607

Open amccarthyMatchbook opened 8 years ago

amccarthyMatchbook commented 8 years ago

Updated Globalize from 1.0.0 to 1.1.0. getting the following error on load.

globalize.js?992e:108 Uncaught Error: E_MISSING_CLDR: Missing required CLDR content supplemental/plurals-type-cardinal/en.

The docs do not say too much except it's an error. https://github.com/jquery/globalize/blob/master/README.md#cldr-errors

E_MISSING_CLDR

Thrown when any required CLDR item is NOT found.

added require( "cldr-data/supplemental/plurals" ) looks to have resolved issue resolved issue.

Any thoughts on why version 1.1.0 requires this and 1.0.0 does not?

rxaviers commented 8 years ago

Hi, thanks for filing the issue, but the provided info isn't enough for reproducing it. Could you please provide a reduced example?

amccarthyMatchbook commented 8 years ago

OSX: Yosemite Browser: Chrome 49.0.2623. node 5.6.0

this is my updated working config, where I have added require( "cldr-data/supplemental/plurals" )

var Globalize = require( "globalize" );

Globalize.load( // Core require( "cldr-data/supplemental/likelySubtags" ), require( "cldr-data/main/en/numbers" ), require('i18n/currencies/usd'), require( "cldr-data/supplemental/plurals" ) ); Globalize.loadMessages( require( "i18n/en/messages" ) );

// Set "en" as our default locale. Globalize.locale( "en" ); window.Globalize = Globalize; module.exports = Globalize;

rxaviers commented 8 years ago

and which formatters are you using in your app, message formatter only? What about your messages, do you use the plural pattern in them?

amccarthyMatchbook commented 8 years ago

Hey thanks for getting back to me. Using formatCurrency, formatNumber & formatMessage. I'm not using plural pattern anywhere in my app.

zedd45 commented 7 years ago

I think I'm encountering a related issue. We just added some translations to our app (zh-Hans and zh-Hant - I think I have the codes correct according to w3), and I'm getting the following error at build time:

Populated the new fields of `messages/zh-hant.json` using the default translation.
Error: E_MISSING_CLDR: Missing required CLDR content `main/zh-hant/numbers/currencies/USD/symbol`.
    at createError (/Users/zedd45/Sites/esports-ui/node_modules/globalize/dist/globalize.js:105:10)
    at validate (/Users/zedd45/Sites/esports-ui/node_modules/globalize/dist/globalize.js:182:9)
    at validateCldr (/Users/zedd45/Sites/esports-ui/node_modules/globalize/dist/globalize.js:204:2)
    at EventEmitter.validateRequiredCldr (/Users/zedd45/Sites/esports-ui/node_modules/globalize/dist/globalize/currency.js:315:2)
    at EventEmitter.emitEvent (/Users/zedd45/Sites/esports-ui/node_modules/cldrjs/dist/cldr/event.js:416:35)
    at EventEmitter.aliasClosure [as trigger] (/Users/zedd45/Sites/esports-ui/node_modules/cldrjs/dist/cldr/event.js:88:22)
    at Cldr.get (/Users/zedd45/Sites/esports-ui/node_modules/cldrjs/dist/cldr/event.js:572:12)
    at Cldr.main (/Users/zedd45/Sites/esports-ui/node_modules/cldrjs/dist/cldr.js:668:15)
    at Object.currencySymbolProperties (/Users/zedd45/Sites/esports-ui/node_modules/globalize/dist/globalize/currency.js:232:17)
    at Function.Globalize.currencyFormatter.Globalize.currencyFormatter [as currencyFormatter] (/Users/zedd45/Sites/esports-ui/node_modules/globalize/dist/globalize/currency.js:356:14)
    at eval (eval at extractor (/Users/zedd45/Sites/esports-ui/node_modules/react-globalize-compiler/lib/extract.js:65:10), <anonymous>:3:19)
    at /Users/zedd45/Sites/esports-ui/node_modules/globalize-compiler/lib/compile-extracts.js:59:23
    at Array.reduce (native)
    at Object.compileExtracts (/Users/zedd45/Sites/esports-ui/node_modules/globalize-compiler/lib/compile-extracts.js:58:49)
    at GlobalizeCompilerHelper.compile (/Users/zedd45/Sites/esports-ui/node_modules/globalize-webpack-plugin/GlobalizeCompilerHelper.js:63:33)
    at /Users/zedd45/Sites/esports-ui/node_modules/globalize-webpack-plugin/ProductionModePlugin.js:231:51
    at RegExp.[Symbol.replace] (native)
    at String.replace (native)
    at /Users/zedd45/Sites/esports-ui/node_modules/globalize-webpack-plugin/ProductionModePlugin.js:225:58
    at Array.forEach (native)
    at /Users/zedd45/Sites/esports-ui/node_modules/globalize-webpack-plugin/ProductionModePlugin.js:223:63
    at Array.forEach (native)
    at Compilation.<anonymous> (/Users/zedd45/Sites/esports-ui/node_modules/globalize-webpack-plugin/ProductionModePlugin.js:221:10)
    at Compilation.applyPlugins (/Users/zedd45/Sites/esports-ui/node_modules/tapable/lib/Tapable.js:26:37)
    at Compilation.<anonymous> (/Users/zedd45/Sites/esports-ui/node_modules/webpack/lib/Compilation.js:558:8)
    at Compilation.next (/Users/zedd45/Sites/esports-ui/node_modules/tapable/lib/Tapable.js:67:11)
    at ExtractTextPlugin.<anonymous> (/Users/zedd45/Sites/esports-ui/node_modules/extract-text-webpack-plugin/index.js:285:5)
    at /Users/zedd45/Sites/esports-ui/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:52:16
    at Object.async.forEachOf.async.eachOf (/Users/zedd45/Sites/esports-ui/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:236:30)
    at Object.async.forEach.async.each (/Users/zedd45/Sites/esports-ui/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:209:22)

FYI I'm using https://github.com/rxaviers/react-globalize-webpack-plugin to generate these, so I'd be happy to file / move this issue there, if it's more approriate.

zedd45 commented 7 years ago

I found a related issue that explains why my use case is failing: https://github.com/globalizejs/globalize/issues/357#issuecomment-66107704

I think I have the wrong languageId

alex-stripe commented 7 years ago

I also got:

Uncaught Error: E_MISSING_CLDR: Missing required CLDR content `supplemental/plurals-type-cardinal/en`.

I'm using the currencyFormatter which uses them for the name style, but I'm not using the name style anywhere. It'd be cool to save the bytes on the data (which I've actually already got loaded in a slightly different format for react-intl message formatting stuff). Not a huge deal though. Just figured I'd flag it.

rxaviers commented 7 years ago

@zedd45 I've moved your issue here https://github.com/rxaviers/globalize-webpack-plugin/issues/67.

@alex-stripe Yeap, if you're using currencyFormatter but not name style, you shouldn't be required to load plural data. Thanks for flagging it too.