chore(common,developer): ldml update to prefinal v44 🙀

- more data and developer fixes

For feat(developer): ldml re-sync with CLDR v44 spec 🙀  #9838
This commit is contained in:
Steven R. Loomis 2023-10-24 17:40:34 -05:00
parent 1ff2bfc4d7
commit a9f437f97a
5 changed files with 33 additions and 33 deletions

View file

@ -168,9 +168,9 @@ export interface LKDisplayOptions {
};
export interface LKDisplay {
to?: string;
output?: string;
display?: string;
id?: string;
keyId?: string;
};
export interface LKDisplays {

View file

@ -11,8 +11,8 @@ import { MarkerTracker, MarkerUse } from "./marker-tracker.js";
export class DispCompiler extends SectionCompiler {
static validateMarkers(keyboard: LDMLKeyboard.LKKeyboard, mt : MarkerTracker): boolean {
keyboard.displays?.display?.forEach(({ to }) =>
mt.add(MarkerUse.match, MarkerParser.allReferences(to)));
keyboard.displays?.display?.forEach(({ output }) =>
mt.add(MarkerUse.match, MarkerParser.allReferences(output)));
// no marker references in 'id'
return true;
}
@ -28,23 +28,23 @@ export class DispCompiler extends SectionCompiler {
const ids = new Set();
if (this.keyboard3.displays?.display) {
for (const { to, id } of this.keyboard3.displays?.display) {
if ((to && id) || (!to && !id)) {
this.callbacks.reportMessage(CompilerMessages.Error_DisplayNeedsToOrId({ to, id }));
for (const { output, keyId } of this.keyboard3.displays?.display) {
if ((output && keyId) || (!output && !keyId)) {
this.callbacks.reportMessage(CompilerMessages.Error_DisplayNeedsToOrId({ output, keyId }));
return false;
} else if (to) {
if (tos.has(to)) {
this.callbacks.reportMessage(CompilerMessages.Error_DisplayIsRepeated({ to }));
} else if (output) {
if (tos.has(output)) {
this.callbacks.reportMessage(CompilerMessages.Error_DisplayIsRepeated({ output }));
return false;
} else {
tos.add(to);
tos.add(output);
}
} else if (id) {
if (ids.has(id)) {
this.callbacks.reportMessage(CompilerMessages.Error_DisplayIsRepeated({ id }));
} else if (keyId) {
if (ids.has(keyId)) {
this.callbacks.reportMessage(CompilerMessages.Error_DisplayIsRepeated({ keyId }));
return false;
} else {
ids.add(id);
ids.add(keyId);
}
}
}
@ -61,12 +61,12 @@ export class DispCompiler extends SectionCompiler {
// displays
result.disps = this.keyboard3.displays?.display.map(display => ({
to: sections.strs.allocString(display.to, {
to: sections.strs.allocString(display.output, {
stringVariables: true,
markers: true,
unescape: true,
}, sections),
id: sections.strs.allocString(display.id), // not escaped, not substituted
id: sections.strs.allocString(display.keyId), // not escaped, not substituted
display: sections.strs.allocString(display.display, {
stringVariables: true,
unescape: true,

View file

@ -59,20 +59,20 @@ export class CompilerMessages {
static FATAL_SectionCompilerFailed = SevFatal | 0x000F;
/** annotate the to= or id= entry */
private static toOrId(o:{to?: string, id?: string}) {
if (o.to && o.id) {
return `to='${o.to}' id='${o.id}'`;
} else if(o.id) {
return `id='${o.id}'`;
} else if (o.to) {
return `to='${o.to}'`;
private static outputOrKeyId(o:{output?: string, keyId?: string}) {
if (o.output && o.keyId) {
return `to='${o.output}' id='${o.keyId}'`;
} else if(o.keyId) {
return `id='${o.keyId}'`;
} else if (o.output) {
return `to='${o.output}'`;
} else {
return '';
}
}
static Error_DisplayIsRepeated = (o:{to?: string, id?: string}) =>
m(this.ERROR_DisplayIsRepeated, `display ${CompilerMessages.toOrId(o)} has more than one display entry.`);
static Error_DisplayIsRepeated = (o:{output?: string, keyId?: string}) =>
m(this.ERROR_DisplayIsRepeated, `display ${CompilerMessages.outputOrKeyId(o)} has more than one display entry.`);
static ERROR_DisplayIsRepeated = SevError | 0x0010;
static Error_KeyMissingToGapOrSwitch = (o:{keyId: string}) =>
@ -140,8 +140,8 @@ export class CompilerMessages {
m(this.ERROR_MissingMarkers, `Markers used for matching but not defined: ${o.ids?.join(',')}`);
static ERROR_MissingMarkers = SevError | 0x0021;
static Error_DisplayNeedsToOrId = (o:{to?: string, id?: string}) =>
m(this.ERROR_DisplayNeedsToOrId, `display ${CompilerMessages.toOrId(o)} needs to= or id=, but not both`);
static Error_DisplayNeedsToOrId = (o:{output?: string, keyId?: string}) =>
m(this.ERROR_DisplayNeedsToOrId, `display ${CompilerMessages.outputOrKeyId(o)} needs output= or keyId=, but not both`);
static ERROR_DisplayNeedsToOrId = SevError | 0x0022;
}

View file

@ -18,7 +18,7 @@
</displays>
<keys>
<key id="hmaqtugha" output="ħ" longPressKeyIds@@="a e" />
<key id="hmaqtugha" output="ħ" longPressKeyIds="a e" />
<key id="that" output="ថា" />
</keys>

View file

@ -19,7 +19,7 @@ describe('disp', function () {
});
it('should compile typical disp', async function() {
let disp = await loadSectionFixture(DispCompiler, 'sections/disp/typical.xml', compilerTestCallbacks) as Disp;
assert.equal(compilerTestCallbacks.messages.length, 0);
assert.equal(compilerTestCallbacks.messages, []);
assert.ok(disp?.disps);
assert.equal(disp.disps.length, 1);
@ -61,13 +61,13 @@ describe('disp', function () {
let disp = await loadSectionFixture(DispCompiler, 'sections/disp/invalid-dupto.xml', compilerTestCallbacks) as Disp;
assert.isNull(disp);
assert.equal(compilerTestCallbacks.messages.length, 1);
assert.deepEqual(compilerTestCallbacks.messages[0], CompilerMessages.Error_DisplayIsRepeated({to:'e'}));
assert.deepEqual(compilerTestCallbacks.messages[0], CompilerMessages.Error_DisplayIsRepeated({output:'e'}));
});
it('should reject duplicate ids', async function() {
let disp = await loadSectionFixture(DispCompiler, 'sections/disp/invalid-dupid.xml', compilerTestCallbacks) as Disp;
assert.isNull(disp);
assert.equal(compilerTestCallbacks.messages.length, 1);
assert.deepEqual(compilerTestCallbacks.messages[0], CompilerMessages.Error_DisplayIsRepeated({id:'e'}));
assert.deepEqual(compilerTestCallbacks.messages[0], CompilerMessages.Error_DisplayIsRepeated({output:'e'}));
});
it('should reject if neither to nor id', async function() {
let disp = await loadSectionFixture(DispCompiler, 'sections/disp/invalid-none.xml', compilerTestCallbacks) as Disp;
@ -79,7 +79,7 @@ describe('disp', function () {
let disp = await loadSectionFixture(DispCompiler, 'sections/disp/invalid-both.xml', compilerTestCallbacks) as Disp;
assert.isNull(disp);
assert.equal(compilerTestCallbacks.messages.length, 1);
assert.deepEqual(compilerTestCallbacks.messages[0], CompilerMessages.Error_DisplayNeedsToOrId({ to: 'e', id: 'e' }));
assert.deepEqual(compilerTestCallbacks.messages[0], CompilerMessages.Error_DisplayNeedsToOrId({ output: 'e', keyId: 'e' }));
});
});