chore(developer): Cleanup multidimensional array to map
- Dominant language
- Pascal
- Stars
- 534
- Forks
- 143
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 113
Description
We are using a multidimensional array here instead of a map, due to the conversion from Delphi. One day should clean this up
_Originally posted by @mcdurdin in https://github.com/keymanapp/keyman/pull/9846#discussion_r1382836481_
Regarding
```
function TransformSpecialKeys14(FDebug: boolean, sLayoutFile: string): string {
// Rewrite Special key labels that are only supported in Keyman 14+
// This code is a little ugly but effective.
if(!IsKeyboardVersion14OrLater()) {
for(let i = 0; i < CSpecialText14Map.length; i++) {
// Assumes the JSON output format will not change
if(FDebug) {
sLayoutFile = sLayoutFile.replaceAll('"text": "'+CSpecialText14Map[i][0]+'"', '"text": this._v>13 ? "'+CSpecialText14Map[i][0]+'" : "'+CSpecialText14Map[i][1]+'"');
} else {
sLayoutFile = sLayoutFile.replaceAll('"text":"'+CSpecialText14Map[i][0]+'"', '"text":this._v>13?"'+CSpecialText14Map[i][0]+'":"'+CSpecialText14Map[i][1]+'"');
}
}
}
return sLayoutFile;
}
function TransformSpecialKeys17(FDebug: boolean, sLayoutFile: string): string {
// Rewrite Special key labels that are only supported in Keyman 17+
// This code is a little ugly but effective.
if(!IsKeyboardVersion17OrLater()) {
for(let i = 0; i < CSpecialText17Map.length; i++) {
// Assumes the JSON output format will not change
if(FDebug) {
sLayoutFile = sLayoutFile.replaceAll('"text": "'+CSpecialText17Map[i][0]+'"', '"text": this._v>16 ? "'+CSpecialText17Map[i][0]+'" : "'+CSpecialText17Map[i][1]+'"');
} else {
sLayoutFile = sLayoutFile.replaceAll('"text":"'+CSpecialText17Map[i][0]+'"', '"text":this._v>16?"'+CSpecialText17Map[i][0]+'":"'+CSpecialText17Map[i][1]+'"');
}
}
}
return sLayoutFile;
}
```
Contributor guide
Research direction
Locate the definitions of CSpecialText14Map and CSpecialText17Map, then inspect TransformSpecialKeys14 and TransformSpecialKeys17. Preserve the existing debug and compact JSON replacement behavior while changing the multidimensional-array representation to maps; done means both transformations produce the same output and existing tests still pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100