Skip to content

Commit 067fe2f

Browse files
committed
feat(mf2): Merge the unsupported-annotation sigil into its source in the data model (unicode-org/message-format-wg#655)
1 parent 4746620 commit 067fe2f

File tree

7 files changed

+4
-18
lines changed

7 files changed

+4
-18
lines changed

packages/mf2-messageformat/src/data-model/from-cst.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ function asExpression(
126126
case 'reserved-annotation':
127127
annotation = {
128128
type: 'unsupported-annotation',
129-
sigil: ca.open.value,
130-
source: ca.source.value
129+
source: ca.open.value + ca.source.value
131130
};
132131
break;
133132
default:

packages/mf2-messageformat/src/data-model/resolve-unsupported-annotation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import type { Literal, UnsupportedAnnotation, VariableRef } from './types.js';
77
export function resolveUnsupportedAnnotation(
88
ctx: Context,
99
operand: Literal | VariableRef | undefined,
10-
{ sigil = '�' }: UnsupportedAnnotation
10+
{ source = '�' }: UnsupportedAnnotation
1111
) {
12+
const sigil = source[0];
1213
const msg = `Reserved ${sigil} annotation is not supported`;
1314
ctx.onError(new MessageResolutionError('unsupported-annotation', msg, sigil));
1415
return fallback(getValueSource(operand) ?? sigil);

packages/mf2-messageformat/src/data-model/stringify.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import type {
1616
Message,
1717
Option,
1818
Pattern,
19-
UnsupportedAnnotation,
2019
VariableRef
2120
} from './types.js';
2221

@@ -136,21 +135,14 @@ function stringifyExpression({ arg, annotation, attributes }: Expression) {
136135
res +=
137136
annotation.type === 'function'
138137
? stringifyFunctionAnnotation(annotation)
139-
: stringifyUnsupportedAnnotation(annotation);
138+
: annotation.source ?? '�';
140139
}
141140
if (attributes) {
142141
for (const attr of attributes) res += ' ' + stringifyAttribute(attr);
143142
}
144143
return `{${res}}`;
145144
}
146145

147-
function stringifyUnsupportedAnnotation({
148-
sigil,
149-
source = '�'
150-
}: UnsupportedAnnotation) {
151-
return (sigil ?? '�') + source;
152-
}
153-
154146
function stringifyVariableRef(ref: VariableRef) {
155147
return '$' + ref.name;
156148
}

packages/mf2-messageformat/src/data-model/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ export interface FunctionAnnotation {
222222
*/
223223
export interface UnsupportedAnnotation {
224224
type: 'unsupported-annotation';
225-
sigil: '!' | '%' | '^' | '&' | '*' | '+' | '<' | '>' | '?' | '~' | '�';
226225
source: string;
227226
name?: never;
228227
options?: never;

packages/mf2-xliff/src/mf2xliff.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@ function resolveExpression({
397397
resFunc = {
398398
type: 'element',
399399
name: 'mf:unsupported',
400-
attributes: { sigil: annotation.sigil ?? '�' },
401400
elements: [asText(annotation.source ?? '�')]
402401
};
403402
}

packages/mf2-xliff/src/xliff-spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,9 +1233,6 @@ export interface MessageOption extends Element {
12331233

12341234
export interface MessageUnsupported extends Element {
12351235
name: 'mf:unsupported';
1236-
attributes: {
1237-
sigil: '!' | '%' | '^' | '&' | '*' | '+' | '<' | '>' | '?' | '~' | '�';
1238-
};
12391236
elements: (Text | CharCode)[];
12401237
}
12411238

packages/mf2-xliff/src/xliff2mf.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ function resolveExpression(elements: X.MessageElements): MF.Expression {
337337
} else {
338338
annotation = {
339339
type: 'unsupported-annotation',
340-
sigil: xFunc.attributes.sigil ?? '�',
341340
source: resolveText(xFunc.elements)
342341
};
343342
}

0 commit comments

Comments
 (0)