Skip to content

Commit 4746620

Browse files
committed
feat(mf2): Drop :plural and :ordinal functions (unicode-org/message-format-wg#621)
1 parent e54254f commit 4746620

File tree

4 files changed

+7
-71
lines changed

4 files changed

+7
-71
lines changed

packages/mf2-messageformat/src/__fixtures/test-functions.json

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -194,44 +194,26 @@
194194
{
195195
"src": ".match {$foo :ordinal} one {{st}} two {{nd}} few {{rd}} * {{th}}",
196196
"params": { "foo": 1 },
197-
"exp": "st"
198-
},
199-
{
200-
"src": ".match {$foo :ordinal} one {{st}} two {{nd}} few {{rd}} * {{th}}",
201-
"params": { "foo": 2 },
202-
"exp": "nd"
203-
},
204-
{
205-
"src": ".match {$foo :ordinal} one {{st}} two {{nd}} few {{rd}} * {{th}}",
206-
"params": { "foo": 3 },
207-
"exp": "rd"
208-
},
209-
{
210-
"src": ".match {$foo :ordinal} one {{st}} two {{nd}} few {{rd}} * {{th}}",
211-
"params": { "foo": 4 },
212-
"exp": "th"
197+
"exp": "th",
198+
"errors": [{ "type": "missing-func" }, { "type": "not-selectable" }]
213199
},
214200
{
215201
"src": "hello {42 :ordinal}",
216202
"exp": "hello {|42|}",
217-
"errors": [{ "type": "not-formattable" }]
203+
"errors": [{ "type": "missing-func" }]
218204
}
219205
],
220206
"plural": [
221207
{
222208
"src": ".match {$foo :plural} one {{one}} * {{other}}",
223209
"params": { "foo": 1 },
224-
"exp": "one"
225-
},
226-
{
227-
"src": ".match {$foo :plural} one {{one}} * {{other}}",
228-
"params": { "foo": 1.1 },
229-
"exp": "other"
210+
"exp": "other",
211+
"errors": [{ "type": "missing-func" }, { "type": "not-selectable" }]
230212
},
231213
{
232214
"src": "hello {42 :plural}",
233215
"exp": "hello {|42|}",
234-
"errors": [{ "type": "not-formattable" }]
216+
"errors": [{ "type": "missing-func" }]
235217
}
236218
],
237219
"string": [

packages/mf2-messageformat/src/functions/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ import type { MessageExpressionPart } from '../formatted-parts.js';
33
export type { MessageFunctionContext } from '../data-model/function-context.js';
44
export { type MessageDateTime, datetime } from './datetime.js';
55
export { type MessageFallback, fallback } from './fallback.js';
6-
export {
7-
type MessageNumber,
8-
integer,
9-
number,
10-
ordinal,
11-
plural
12-
} from './number.js';
6+
export { type MessageNumber, integer, number } from './number.js';
137
export { type MessageString, string } from './string.js';
148
export { type MessageUnknownValue, unknown } from './unknown.js';
159

packages/mf2-messageformat/src/functions/number.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -182,39 +182,3 @@ export const integer = (
182182
{ ...options, maximumFractionDigits: 0, style: 'decimal' },
183183
input
184184
);
185-
186-
/**
187-
* `ordinal` accepts a number, BigInt or string representing a JSON number as input
188-
* and acts as a ordinal category selector on the value, using
189-
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules | Intl.PluralRules}.
190-
*
191-
* `ordinal` cannot be used as a formatter.
192-
*
193-
* @beta
194-
*/
195-
export const ordinal = (
196-
ctx: MessageFunctionContext,
197-
options: Record<string, unknown>,
198-
input?: unknown
199-
) =>
200-
number(ctx, { ...options, select: 'ordinal', [NotFormattable]: true }, input);
201-
202-
/**
203-
* `plural` accepts a number, BigInt or string representing a JSON number as input
204-
* and acts as a cardinal plural selector on the value, using
205-
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules | Intl.PluralRules}.
206-
*
207-
* `plural` cannot be used as a formatter.
208-
*
209-
* @beta
210-
*/
211-
export const plural = (
212-
ctx: MessageFunctionContext,
213-
options: Record<string, unknown>,
214-
input?: unknown
215-
) =>
216-
number(
217-
ctx,
218-
{ ...options, select: 'cardinal', [NotFormattable]: true },
219-
input
220-
);

packages/mf2-messageformat/src/messageformat.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import {
1818
datetime,
1919
integer,
2020
number,
21-
ordinal,
22-
plural,
2321
string
2422
} from './functions/index.js';
2523
import { selectPattern } from './select-pattern.js';
@@ -28,8 +26,6 @@ const defaultFunctions = Object.freeze({
2826
datetime,
2927
integer,
3028
number,
31-
ordinal,
32-
plural,
3329
string
3430
});
3531

0 commit comments

Comments
 (0)