如何确保 Int.NumberFormat 在使用同一个国家时不显示货币代码?

How to ensure Int.NumberFormat does not show currency code when using the same country?

给定区域设置 fr-CA,在 CAD 中显示货币值,我怎样才能让国家代码 不显示 ?因为 en-CA 显示 ".00"fr-CA 显示 "1.00 $ CAD" 没有明显的原因。

请参阅下面的代码片段:

[
  'fr-CA',
  'en-CA',
  'en-US'
].forEach(locale => {
   document.getElementById('label_' + locale).innerHTML = new Intl.NumberFormat(locale, { style: 'currency', currency: 'CAD' }).format(0.25);
});
.currency {
  padding-right: 10px;
}

.error {
  color: white;
  background-color: red;
  font-weight: 900;
  padding: 0 10px;
}

.success {
  color: green;
}
<p>Should <strong>not</strong> display CAD because same country (fr-CA)</p>
<span class="currency" id="label_fr-CA"></span><span class="error">err!</span>
<p>Should not display CAD because same country (en-CA)</p>
<span class="currency" id="label_en-CA"></span><span class="success">OK</span>
<p>Should display CAD because different country (en-US)</p>
<span class="currency" id="label_en-US"></span><span class="success">OK</span>

为什么在两个具有相同国家代码的区域设置中显示的国家不一致,这可以正常化吗?

** 编辑 **

这是我在浏览器中看到的,因为我的语言环境当前设置为“fr”:

地区"fr-CA"显示0,25 $ CA"en-CA"显示[=23=].25;两个语言环境都有相同的国家代码(即 CA),这也与货币国家代码相同,那么为什么国家代码显示为 "fr-CA"" 而不是 "en-CA"

使用不同的浏览器,将区域设置设置为 "en-CA",一切都会按应有的方式显示。那么,为什么 Intl.NumberFormat 与它接收到的值不一致,因为它 询问 语言环境,但最终取决于它黑匣子内的浏览器语言环境?

根据 Randy Casburn 的评论,我打开了一个关于 tc39 / ecma402 repository, and the discussion went from there to the CLDR but 报告的问题,其中指出

250 CAD in fr-CA should be 250,00 $
250 CAD in en-CA should be 0.00
250 CAD in fr-FR should be 250,00 $ CA
250 CAD in en-US should be Can0.00/CAN0.00

换句话说,正如这个问题所问的那样。

解决方案是这很可能会在下一个版本中得到解决。目前,下一个版本是 v40,计划于 2021 年 10 月发布。

注意:当前行为在浏览器之间不一致。例如,Firefox 当前不显示此行为,但 Chrome 显示。希望有一天,所有浏览器都将符合相同的规范。