Skip to content

Commit 9504dcd

Browse files
nadalabaMiodec
andauthored
chore(languages): rename ligatures to joiningScript (@nadalaba) (#7788)
Co-authored-by: Jack <jack@monkeytype.com>
1 parent a09c214 commit 9504dcd

115 files changed

Lines changed: 108 additions & 159 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/LANGUAGES.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@ The contents of the file should be as follows:
2121
{
2222
"name": string,
2323
"rightToLeft": boolean,
24-
"ligatures": boolean,
24+
"joiningScript": boolean,
2525
"orderedByFrequency": boolean,
2626
"bcp47": string,
2727
"words": string[]
2828
}
2929
```
3030

31-
It is recommended that you familiarize yourselves with JSON before adding a language. For the `name` field, put the name of your language. `rightToLeft` indicates how the language is written. If it is written right to left then put `true`, otherwise put `false`.
32-
`ligatures` A ligature occurs when multiple letters are joined together to form a character [more details](<https://en.wikipedia.org/wiki/Ligature_(writing)>). If there's joining in the words, which is the case in languages like (Arabic, Malayalam, Persian, Sanskrit, Central_Kurdish... etc.), then set the value to `true`, otherwise set it to `false`. For `bcp47` put your languages [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag). If the words you're adding are ordered by frequency (most common words at the top, least at the bottom) set the value of `orderedByFrequency` to `true`, otherwise `false`. Finally, add your list of words to the `words` field.
31+
It is recommended that you familiarize yourselves with JSON before adding a language. For the `name` field, put the name of your language.
32+
`rightToLeft` indicates how the language is written. If it is written right to left then put `true`, otherwise put `false`.
33+
`joiningScript` indicates whether the language requires joining letters to render correctly. Set it to `true` if characters must join with surrounding characters or if their shapes change based on position in a word (initial, medial, final, or isolated), or if they use connecting marks (matras/vowel signs) that reshape the base characters. Otherwise, set it to `false.`
34+
For `bcp47` put your languages [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag).
35+
If the words you're adding are ordered by frequency (most common words at the top, least at the bottom) set the value of `orderedByFrequency` to `true`, otherwise `false`.
36+
Finally, add your list of words to the `words` field.
3337

3438
Then, go to `packages/schemas/src/languages.ts` and add your new language name at the _end_ of the `LanguageSchema` enum. Make sure to end the line with a comma. Make sure to add all your language names if you have created multiple word lists of differing lengths in the same language.
3539

frontend/src/styles/test.scss

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@
320320
unicode-bidi: bidi-override;
321321
}
322322
}
323-
&.withLigatures {
323+
&.joiningScript {
324324
.word {
325325
overflow-wrap: anywhere;
326326
padding-bottom: 0.05em; // compensate for letter border
@@ -531,8 +531,8 @@
531531
&.typed-effect-dots {
532532
/* transform already typed letters into appropriately colored dots */
533533

534-
&:not(.withLigatures) .word,
535-
&.withLigatures .word.broken-ligatures {
534+
&:not(.joiningScript) .word,
535+
&.joiningScript .word.broken-joining {
536536
letter {
537537
position: relative;
538538
display: inline-block;
@@ -550,17 +550,17 @@
550550
}
551551
}
552552
// unify dot spacing
553-
&.withLigatures .word.broken-ligatures {
553+
&.joiningScript .word.broken-joining {
554554
letter {
555555
width: 0.4em;
556556
}
557557
}
558-
.word.broken-ligatures:not(.needs-wrap) {
558+
.word.broken-joining:not(.needs-wrap) {
559559
white-space: nowrap;
560560
}
561561

562-
&:not(.withLigatures) .word.typed,
563-
&.withLigatures .word.broken-ligatures.typed {
562+
&:not(.joiningScript) .word.typed,
563+
&.joiningScript .word.broken-joining.typed {
564564
letter {
565565
color: var(--bg-color);
566566
animation: typedEffectToDust 200ms ease-out 0ms 1 forwards !important;
@@ -571,18 +571,18 @@
571571
}
572572
}
573573

574-
&:not(.withLigatures):not(.blind) {
574+
&:not(.joiningScript):not(.blind) {
575575
.word letter.incorrect::after {
576576
background: var(--c-dot--error);
577577
}
578578
}
579-
&.withLigatures:not(.blind) .word.broken-ligatures letter.incorrect::after {
579+
&.joiningScript:not(.blind) .word.broken-joining letter.incorrect::after {
580580
background: var(--c-dot--error);
581581
}
582582

583583
@media (prefers-reduced-motion) {
584-
&:not(.withLigatures) .word.typed,
585-
&.withLigatures .word.broken-ligatures.typed {
584+
&:not(.joiningScript) .word.typed,
585+
&.joiningScript .word.broken-joining.typed {
586586
letter {
587587
animation: none !important;
588588
transform: scale(0.4);
@@ -874,7 +874,7 @@
874874
unicode-bidi: bidi-override;
875875
}
876876
}
877-
&.withLigatures {
877+
&.joiningScript {
878878
.word {
879879
overflow-wrap: anywhere;
880880
padding-bottom: 2px; // compensate for letter border
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { ElementWithUtils } from "../utils/dom";
33

44
function canBreak(wordEl: ElementWithUtils): boolean {
55
if (Config.typedEffect !== "dots") return false;
6-
if (wordEl.hasClass("broken-ligatures")) return false;
6+
if (wordEl.hasClass("broken-joining")) return false;
77

8-
return wordEl.getParent()?.hasClass("withLigatures") ?? false;
8+
return wordEl.getParent()?.hasClass("joiningScript") ?? false;
99
}
1010

1111
function applyIfNeeded(wordEl: ElementWithUtils): void {
@@ -25,28 +25,25 @@ function applyIfNeeded(wordEl: ElementWithUtils): void {
2525
wordEl.setStyle({ width: "" });
2626
wordEl.addClass("needs-wrap");
2727
}
28-
wordEl.addClass("broken-ligatures");
28+
wordEl.addClass("broken-joining");
2929
}
3030

3131
function reset(wordEl: ElementWithUtils): void {
32-
if (!wordEl.hasClass("broken-ligatures")) return;
33-
wordEl.removeClass("broken-ligatures");
32+
if (!wordEl.hasClass("broken-joining")) return;
33+
wordEl.removeClass("broken-joining");
3434
wordEl.removeClass("needs-wrap");
3535
wordEl.setStyle({ width: "" });
3636
}
3737

38-
export function set(
39-
wordEl: ElementWithUtils,
40-
areLigaturesBroken: boolean,
41-
): void {
42-
areLigaturesBroken ? applyIfNeeded(wordEl) : reset(wordEl);
38+
export function set(wordEl: ElementWithUtils, joiningBroken: boolean): void {
39+
joiningBroken ? applyIfNeeded(wordEl) : reset(wordEl);
4340
}
4441

4542
export function update(key: string, wordsEl: ElementWithUtils): void {
4643
const words = wordsEl.qsa(".word.typed");
4744

4845
const shouldReset =
49-
!wordsEl.hasClass("withLigatures") ||
46+
!wordsEl.hasClass("joiningScript") ||
5047
Config.typedEffect !== "dots" ||
5148
key === "fontFamily" ||
5249
key === "fontSize";

frontend/src/ts/test/funbox/funbox-functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ const list: Partial<Record<FunboxName, FunboxFunctions>> = {
747747
lang.name,
748748
{
749749
noLazyMode: lang.noLazyMode,
750-
ligatures: lang.ligatures,
750+
joiningScript: lang.joiningScript,
751751
rightToLeft: lang.rightToLeft,
752752
additionalAccents: lang.additionalAccents,
753753
},

frontend/src/ts/test/funbox/funbox.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ export async function activate(
115115
return false;
116116
}
117117

118-
if (language.ligatures) {
119-
if (isFunboxActiveWithProperty("noLigatures")) {
118+
if (language.joiningScript) {
119+
if (isFunboxActiveWithProperty("noJoiningScript")) {
120120
showNoticeNotification(
121121
"Current language does not support this funbox mode",
122122
);

frontend/src/ts/test/test-logic.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ async function init(): Promise<boolean> {
518518
let wordsHaveTab = false;
519519
let wordsHaveNewline = false;
520520
let allRightToLeft: boolean | undefined = undefined;
521-
let allLigatures: boolean | undefined = undefined;
521+
let allJoiningScript: boolean | undefined = undefined;
522522
let generatedWords: string[] = [];
523523
let generatedSectionIndexes: number[] = [];
524524
try {
@@ -527,7 +527,7 @@ async function init(): Promise<boolean> {
527527
generatedSectionIndexes = gen.sectionIndexes;
528528
wordsHaveTab = gen.hasTab;
529529
wordsHaveNewline = gen.hasNewline;
530-
({ allRightToLeft, allLigatures } = gen);
530+
({ allRightToLeft, allJoiningScript } = gen);
531531
} catch (e) {
532532
hideLoaderBar();
533533
if (e instanceof WordGenError || e instanceof Error) {
@@ -590,8 +590,9 @@ async function init(): Promise<boolean> {
590590
) as string,
591591
);
592592
}
593+
593594
Funbox.toggleScript(TestWords.words.getCurrentText());
594-
TestUI.setLigatures(allLigatures ?? language.ligatures ?? false);
595+
TestUI.setJoiningClass(allJoiningScript ?? language.joiningScript ?? false);
595596

596597
const isLanguageRTL = allRightToLeft ?? language.rightToLeft ?? false;
597598
TestState.setIsLanguageRightToLeft(isLanguageRTL);

frontend/src/ts/test/test-ui.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import * as MonkeyPower from "../elements/monkey-power";
5252
import * as SlowTimer from "../legacy-states/slow-timer";
5353
import * as CompositionDisplay from "../elements/composition-display";
5454
import * as AdController from "../controllers/ad-controller";
55-
import * as Ligatures from "./break-ligatures";
55+
import * as Joining from "./break-joining";
5656
import * as LayoutfluidFunboxTimer from "../test/funbox/layoutfluid-funbox-timer";
5757
import * as Keymap from "../elements/keymap";
5858
import * as ThemeController from "../controllers/theme-controller";
@@ -147,7 +147,7 @@ export function updateActiveElement(
147147
if (previousActiveWord !== null) {
148148
if (direction === "forward") {
149149
previousActiveWord.addClass("typed");
150-
Ligatures.set(previousActiveWord, true);
150+
Joining.set(previousActiveWord, true);
151151
} else if (direction === "back") {
152152
//
153153
}
@@ -164,7 +164,7 @@ export function updateActiveElement(
164164
newActiveWord.addClass("active");
165165
newActiveWord.removeClass("error");
166166
newActiveWord.removeClass("typed");
167-
Ligatures.set(newActiveWord, false);
167+
Joining.set(newActiveWord, false);
168168

169169
activeWordTop = newActiveWord.getOffsetTop();
170170
activeWordHeight = newActiveWord.getOffsetHeight();
@@ -1238,15 +1238,15 @@ export async function lineJump(
12381238
return;
12391239
}
12401240

1241-
export function setLigatures(isEnabled: boolean): void {
1241+
export function setJoiningClass(isEnabled: boolean): void {
12421242
if (isEnabled || Config.mode === "custom" || Config.mode === "zen") {
1243-
wordsEl.addClass("withLigatures");
1244-
qs("#resultWordsHistory .words")?.addClass("withLigatures");
1245-
qs("#resultReplay .words")?.addClass("withLigatures");
1243+
wordsEl.addClass("joiningScript");
1244+
qs("#resultWordsHistory .words")?.addClass("joiningScript");
1245+
qs("#resultReplay .words")?.addClass("joiningScript");
12461246
} else {
1247-
wordsEl.removeClass("withLigatures");
1248-
qs("#resultWordsHistory .words")?.removeClass("withLigatures");
1249-
qs("#resultReplay .words")?.removeClass("withLigatures");
1247+
wordsEl.removeClass("joiningScript");
1248+
qs("#resultWordsHistory .words")?.removeClass("joiningScript");
1249+
qs("#resultReplay .words")?.removeClass("joiningScript");
12501250
}
12511251
}
12521252

@@ -2079,7 +2079,7 @@ configEvent.subscribe(({ key, newValue }) => {
20792079
) {
20802080
if (key !== "fontFamily") updateWordWrapperClasses();
20812081
if (["typedEffect", "fontFamily", "fontSize"].includes(key)) {
2082-
Ligatures.update(key, wordsEl);
2082+
Joining.update(key, wordsEl);
20832083
}
20842084
}
20852085
if (["tapeMode", "tapeMargin"].includes(key)) {

frontend/src/ts/test/words-generator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ type GenerateWordsReturn = {
602602
hasTab: boolean;
603603
hasNewline: boolean;
604604
allRightToLeft?: boolean;
605-
allLigatures?: boolean;
605+
allJoiningScript?: boolean;
606606
};
607607

608608
let previousRandomQuote: QuoteWithTextSplit | null = null;
@@ -625,7 +625,7 @@ export async function generateWords(
625625
hasTab: false,
626626
hasNewline: false,
627627
allRightToLeft: language.rightToLeft,
628-
allLigatures: language.ligatures ?? false,
628+
allJoiningScript: language.joiningScript ?? false,
629629
};
630630

631631
isCurrentlyUsingFunboxSection = isFunboxActiveWithFunction("pullSection");
@@ -661,10 +661,10 @@ export async function generateWords(
661661
if (result instanceof PolyglotWordset) {
662662
const polyglotResult = result;
663663
currentWordset = polyglotResult;
664-
// set allLigatures if any language in languageProperties has ligatures true
665-
ret.allLigatures = Array.from(
664+
// set allJoiningScript if any language in languageProperties has joiningScript: true
665+
ret.allJoiningScript = Array.from(
666666
polyglotResult.languageProperties.values(),
667-
).some((props) => !!props.ligatures);
667+
).some((props) => !!props.joiningScript);
668668
} else {
669669
currentWordset = result;
670670
}

frontend/src/ts/utils/json-data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export async function getLayout(layoutName: string): Promise<LayoutObject> {
8282
// used for polyglot wordset language-specific properties
8383
export type LanguageProperties = Pick<
8484
LanguageObject,
85-
"noLazyMode" | "ligatures" | "rightToLeft" | "additionalAccents"
85+
"noLazyMode" | "joiningScript" | "rightToLeft" | "additionalAccents"
8686
>;
8787

8888
let currentLanguage: LanguageObject;

frontend/static/funbox/backwards.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
direction: ltr;
77
}
88

9-
#words.withLigatures .word {
9+
#words.joiningScript .word {
1010
unicode-bidi: bidi-override;
1111
}

0 commit comments

Comments
 (0)