/home/johndoe/repos/experiment-globalize/node_modules/globalize/dist/globalize.js:73
message = message.replace( /{[0-9a-zA-Z-_. ]+}/g, function( name ) {
^
TypeError: Cannot read properties of undefined (reading 'replace')
at formatMessage (/home/johndoe/repos/experiment-globalize/node_modules/globalize/dist/globalize.js:73:20)
at unitFormat (/home/johndoe/repos/experiment-globalize/node_modules/globalize/dist/globalize/unit.js:90:9)
at unitFormatter (/home/johndoe/repos/experiment-globalize/node_modules/globalize/dist/globalize/unit.js:101:10)
at Object.<anonymous> (/home/johndoe/repos/experiment-globalize/src/index.js:7:73)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
This is because the data in cldr-data@36.0.1 is inconsistent. Under node_modules/cldr-data/main/pl/units.json, the short.digital-megabyte only contains strings for plural form of "other". It is lacking strings for "one", "few" and "many".
Excerpt from pl/units.json showing the short form of digital-megabyte only has string for "other" plural form:
Excerpt from supplemental/plurals.json showing Polish has 4 plural forms of "one", "few", "many" and "other":
"pl": {
"pluralRule-count-one": "i = 1 and v = 0 @integer 1",
"pluralRule-count-few": "v = 0 and i % 10 = 2..4 and i % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, …",
"pluralRule-count-many": "v = 0 and i != 1 and i % 10 = 0..1 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 12..14 @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, …",
"pluralRule-count-other": " @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …"
},
However, when formatting 1.1, it can format it into "1,1 MB". When formatting 1 into long form, it can format it into "1 megabajt".
Following packages are installed (latest as of now):
cldr-data@36.0.1
globalize@1.7.0
iana-tz-data@2019.1.0
When using the following code to format megabytes in short form in Polish, it failed:
The error is:
This is because the data in
cldr-data@36.0.1
is inconsistent. Undernode_modules/cldr-data/main/pl/units.json
, theshort.digital-megabyte
only contains strings for plural form of "other". It is lacking strings for "one", "few" and "many".Excerpt from
pl/units.json
showing the short form ofdigital-megabyte
only has string for "other" plural form:Excerpt from
supplemental/plurals.json
showing Polish has 4 plural forms of "one", "few", "many" and "other":However, when formatting
1.1
, it can format it into"1,1 MB"
. When formatting1
into long form, it can format it into"1 megabajt"
.