Skip to content

Commit b4ae017

Browse files
feat(mf2)!: Drop :currency currencyDisplay=formalSymbol option value (unicode-org/message-format-wg#985)
1 parent efd3254 commit b4ae017

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

mf2/messageformat/src/functions/currency.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ describe('currencyDisplay', () => {
2727
'symbol',
2828
'name',
2929
'code',
30-
'formalSymbol',
3130
'never'
32-
]) {
31+
] as const) {
3332
test(`currencyDisplay=${cd}`, () => {
3433
const mf = new MessageFormat(
3534
'en',
@@ -38,15 +37,14 @@ describe('currencyDisplay', () => {
3837
const nf = new Intl.NumberFormat('en', {
3938
style: 'currency',
4039
currency: 'EUR',
41-
currencyDisplay:
42-
cd === 'formalSymbol' || cd === 'never' ? undefined : cd
40+
currencyDisplay: cd === 'never' ? undefined : cd
4341
});
4442
const onError = jest.fn();
4543
expect(mf.format(undefined, onError)).toEqual(nf.format(42));
4644
expect(mf.formatToParts(undefined, onError)).toMatchObject([
4745
{ parts: nf.formatToParts(42) }
4846
]);
49-
if (cd === 'formalSymbol' || cd === 'never') {
47+
if (cd === 'never') {
5048
expect(onError.mock.calls).toMatchObject([
5149
[{ type: 'unsupported-operation' }],
5250
[{ type: 'unsupported-operation' }]

mf2/messageformat/src/functions/currency.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,18 @@ export function currency(
4848
break;
4949
case 'currencyDisplay': {
5050
const strval = asString(optval);
51-
if (strval === 'formalSymbol' || strval === 'never') {
52-
throw new MessageResolutionError(
53-
'unsupported-operation',
54-
`Currency display "${strval}" is not supported on :currency`,
55-
source
51+
if (strval === 'never') {
52+
ctx.onError(
53+
new MessageResolutionError(
54+
'unsupported-operation',
55+
'Currency display "never" is not yet supported',
56+
source
57+
)
5658
);
59+
} else {
60+
// @ts-expect-error Let Intl.NumberFormat construction fail
61+
options[name] = strval;
5762
}
58-
// @ts-expect-error Let Intl.NumberFormat construction fail
59-
options[name] = strval;
6063
break;
6164
}
6265
case 'fractionDigits': {

0 commit comments

Comments
 (0)