Description
- Version:
$ node -v
v12.10.0
- Platform: Mac OS & Ubuntu
$ uname -a
Darwin username 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64
$ uname -a
Linux ip-172-31-90-221 4.15.0-1045-aws #47-Ubuntu SMP Fri Aug 2 13:50:30 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Intro to my problem
I looked at the video from Google IO 2019 that talked about the latest features in javascript, and there was a part on improvement on Intl
API and I wanted to try it out myself by using the latest version of node (12.10.0
at this time of writing):
and I confirmed again that the new features for Intl
work on node v.12+ from these articles:
from v8's blog as well.
These are the things I tested on my laptop (mac OS) and also on my AWS EC2 Ubuntu instance (because I wanted to be as objective as possible):
Problem description
Mac OS
$ node
Welcome to Node.js v12.10.0.
Type ".help" for more information.
> const rtf = new Intl.RelativeTimeFormat('ta-in', { numeric: 'auto' })
undefined
>
> rtf.format(-1, 'day')
'yesterday'
> rtf.format(0, 'day')
'today'
> rtf.format(1, 'day')
'tomorrow'
> rtf.format(-1, 'week')
'last week'
> rtf.format(0, 'week')
'this week'
> rtf.format(1, 'week')
'next week'
>
> const lf1 = new Intl.ListFormat('hi-in')
undefined
> lf1.format(['a', 'b'])
'a and b'
> lf1.format(['a', 'b', 'c'])
'a, b, and c'
>
> const lf2 = new Intl.ListFormat('hi-in', { type: 'disjunction'})
undefined
> lf2.format(['a', 'b'])
'a or b'
> lf2.format(['a', 'b', 'c'])
'a, b, or c'
Ubuntu 18.04
ubuntu:~/environment $ node
Welcome to Node.js v12.10.0.
Type ".help" for more information.
> const rtf = new Intl.RelativeTimeFormat('ta-in', { numeric: 'auto' })
undefined
>
> rtf.format(-1, 'day')
'yesterday'
> rtf.format(0, 'day')
'today'
> rtf.format(1, 'day')
'tomorrow'
> rtf.format(-1, 'week')
'last week'
> rtf.format(0, 'week')
'this week'
> rtf.format(1, 'week')
'next week'
>
> const lf1 = new Intl.ListFormat('hi-in')
undefined
> lf1.format(['a', 'b'])
'a and b'
> lf1.format(['a', 'b', 'c'])
'a, b, and c'
>
> const lf2 = new Intl.ListFormat('hi-in', { type: 'disjunction'})
undefined
> lf2.format(['a', 'b'])
'a or b'
> lf2.format(['a', 'b', 'c'])
'a, b, or c'
>
Chrome 76 (on my mac)
const rtf = new Intl.RelativeTimeFormat('ta-in', { numeric: 'auto' })
console.log(
rtf.format(-1, 'day'),
rtf.format(0, 'day'),
rtf.format(1, 'day'),
rtf.format(-1, 'week'),
rtf.format(0, 'week'),
rtf.format(1, 'week'))
const lf1 = new Intl.ListFormat('hi-in')
console.log(
lf1.format(['a', 'b']),
lf1.format(['a', 'b', 'c']))
const lf2 = new Intl.ListFormat('hi-in', { type: 'disjunction'})
console.log(
lf2.format(['a', 'b']),
lf2.format(['a', 'b', 'c']))
// result
vendors~main.257badf6.chunk.js:38 நேற்று இன்று நாளை கடந்த வாரம் இந்த வாரம் அடுத்த வாரம்
vendors~main.257badf6.chunk.js:38 a और b a, b, और c
vendors~main.257badf6.chunk.js:38 a या b a, b या c
FYI, I used the code snippets from Google IO 2019 to avoid writing stupid things by mistake. Yeap. As you can see, Chrome 76 perfectly outputs what's expected, while node repl on both operating systems did not work as expected. They only give outputs in English, which I think is a default fallback option.
If this is real, I think it is a huge error, so I am still in a big doubt thinking if node v.12+ really supports these features. Is this really a bug?!??