Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/LANGUAGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ The contents of the file should be as follows:
{
"name": string,
"rightToLeft": boolean,
"ligatures": boolean,
"cursiveScript": boolean,
"orderedByFrequency": boolean,
"bcp47": string,
"words": string[]
}
```

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`.
`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.
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`.
`cursiveScript` indicates whether the language requires cursive joining 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). 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.

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.

Expand Down
24 changes: 12 additions & 12 deletions frontend/src/styles/test.scss
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
unicode-bidi: bidi-override;
}
}
&.withLigatures {
&.cursiveScript {
.word {
overflow-wrap: anywhere;
padding-bottom: 0.05em; // compensate for letter border
Expand Down Expand Up @@ -536,8 +536,8 @@
&.typed-effect-dots {
/* transform already typed letters into appropriately colored dots */

&:not(.withLigatures) .word,
&.withLigatures .word.broken-ligatures {
&:not(.cursiveScript) .word,
&.cursiveScript .word.broken-cursive {
letter {
position: relative;
display: inline-block;
Expand All @@ -555,17 +555,17 @@
}
}
// unify dot spacing
&.withLigatures .word.broken-ligatures {
&.cursiveScript .word.broken-cursive {
letter {
width: 0.4em;
}
}
.word.broken-ligatures:not(.needs-wrap) {
.word.broken-cursive:not(.needs-wrap) {
white-space: nowrap;
}

&:not(.withLigatures) .word.typed,
&.withLigatures .word.broken-ligatures.typed {
&:not(.cursiveScript) .word.typed,
&.cursiveScript .word.broken-cursive.typed {
letter {
color: var(--bg-color);
animation: typedEffectToDust 200ms ease-out 0ms 1 forwards !important;
Expand All @@ -576,18 +576,18 @@
}
}

&:not(.withLigatures):not(.blind) {
&:not(.cursiveScript):not(.blind) {
.word letter.incorrect::after {
background: var(--c-dot--error);
}
}
&.withLigatures:not(.blind) .word.broken-ligatures letter.incorrect::after {
&.cursiveScript:not(.blind) .word.broken-cursive letter.incorrect::after {
background: var(--c-dot--error);
}

@media (prefers-reduced-motion) {
&:not(.withLigatures) .word.typed,
&.withLigatures .word.broken-ligatures.typed {
&:not(.cursiveScript) .word.typed,
&.cursiveScript .word.broken-cursive.typed {
letter {
animation: none !important;
transform: scale(0.4);
Expand Down Expand Up @@ -880,7 +880,7 @@
unicode-bidi: bidi-override;
}
}
&.withLigatures {
&.cursiveScript {
.word {
overflow-wrap: anywhere;
padding-bottom: 2px; // compensate for letter border
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { ElementWithUtils } from "../utils/dom";

function canBreak(wordEl: ElementWithUtils): boolean {
if (Config.typedEffect !== "dots") return false;
if (wordEl.hasClass("broken-ligatures")) return false;
if (wordEl.hasClass("broken-cursive")) return false;

return wordEl.getParent()?.hasClass("withLigatures") ?? false;
return wordEl.getParent()?.hasClass("cursiveScript") ?? false;
}

function applyIfNeeded(wordEl: ElementWithUtils): void {
Expand All @@ -25,28 +25,25 @@ function applyIfNeeded(wordEl: ElementWithUtils): void {
wordEl.setStyle({ width: "" });
wordEl.addClass("needs-wrap");
}
wordEl.addClass("broken-ligatures");
wordEl.addClass("broken-cursive");
}

function reset(wordEl: ElementWithUtils): void {
if (!wordEl.hasClass("broken-ligatures")) return;
wordEl.removeClass("broken-ligatures");
if (!wordEl.hasClass("broken-cursive")) return;
wordEl.removeClass("broken-cursive");
wordEl.removeClass("needs-wrap");
wordEl.setStyle({ width: "" });
}

export function set(
wordEl: ElementWithUtils,
areLigaturesBroken: boolean,
): void {
areLigaturesBroken ? applyIfNeeded(wordEl) : reset(wordEl);
export function set(wordEl: ElementWithUtils, cursiveBroken: boolean): void {
cursiveBroken ? applyIfNeeded(wordEl) : reset(wordEl);
}

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

const shouldReset =
!wordsEl.hasClass("withLigatures") ||
!wordsEl.hasClass("cursiveScript") ||
Config.typedEffect !== "dots" ||
key === "fontFamily" ||
key === "fontSize";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/test/funbox/funbox-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ const list: Partial<Record<FunboxName, FunboxFunctions>> = {
lang.name,
{
noLazyMode: lang.noLazyMode,
ligatures: lang.ligatures,
cursiveScript: lang.cursiveScript,
rightToLeft: lang.rightToLeft,
additionalAccents: lang.additionalAccents,
},
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/ts/test/funbox/funbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ export async function activate(
return false;
}

if (language.ligatures) {
if (isFunboxActiveWithProperty("noLigatures")) {
if (language.cursiveScript) {
if (isFunboxActiveWithProperty("noCursive")) {
showNoticeNotification(
"Current language does not support this funbox mode",
);
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/ts/test/test-logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ async function init(): Promise<boolean> {
let wordsHaveTab = false;
let wordsHaveNewline = false;
let allRightToLeft: boolean | undefined = undefined;
let allLigatures: boolean | undefined = undefined;
let allCursiveScript: boolean | undefined = undefined;
let generatedWords: string[] = [];
let generatedSectionIndexes: number[] = [];
try {
Expand All @@ -524,7 +524,7 @@ async function init(): Promise<boolean> {
generatedSectionIndexes = gen.sectionIndexes;
wordsHaveTab = gen.hasTab;
wordsHaveNewline = gen.hasNewline;
({ allRightToLeft, allLigatures } = gen);
({ allRightToLeft, allCursiveScript } = gen);
} catch (e) {
hideLoaderBar();
if (e instanceof WordGenError || e instanceof Error) {
Expand Down Expand Up @@ -588,7 +588,7 @@ async function init(): Promise<boolean> {
);
}
Funbox.toggleScript(TestWords.words.getCurrent());
TestUI.setLigatures(allLigatures ?? language.ligatures ?? false);
TestUI.setCursiveClass(allCursiveScript ?? language.cursiveScript ?? false);

const isLanguageRTL = allRightToLeft ?? language.rightToLeft ?? false;
TestState.setIsLanguageRightToLeft(isLanguageRTL);
Expand Down
22 changes: 11 additions & 11 deletions frontend/src/ts/test/test-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import * as MonkeyPower from "../elements/monkey-power";
import * as SlowTimer from "../legacy-states/slow-timer";
import * as CompositionDisplay from "../elements/composition-display";
import * as AdController from "../controllers/ad-controller";
import * as Ligatures from "./break-ligatures";
import * as Cursive from "./break-cursive";
import * as LayoutfluidFunboxTimer from "../test/funbox/layoutfluid-funbox-timer";
import * as Keymap from "../elements/keymap";
import * as ThemeController from "../controllers/theme-controller";
Expand Down Expand Up @@ -147,7 +147,7 @@ export function updateActiveElement(
if (previousActiveWord !== null) {
if (direction === "forward") {
previousActiveWord.addClass("typed");
Ligatures.set(previousActiveWord, true);
Cursive.set(previousActiveWord, true);
} else if (direction === "back") {
//
}
Expand All @@ -164,7 +164,7 @@ export function updateActiveElement(
newActiveWord.addClass("active");
newActiveWord.removeClass("error");
newActiveWord.removeClass("typed");
Ligatures.set(newActiveWord, false);
Cursive.set(newActiveWord, false);

activeWordTop = newActiveWord.getOffsetTop();
activeWordHeight = newActiveWord.getOffsetHeight();
Expand Down Expand Up @@ -1240,15 +1240,15 @@ export async function lineJump(
return;
}

export function setLigatures(isEnabled: boolean): void {
export function setCursiveClass(isEnabled: boolean): void {
if (isEnabled || Config.mode === "custom" || Config.mode === "zen") {
wordsEl.addClass("withLigatures");
qs("#resultWordsHistory .words")?.addClass("withLigatures");
qs("#resultReplay .words")?.addClass("withLigatures");
wordsEl.addClass("cursiveScript");
qs("#resultWordsHistory .words")?.addClass("cursiveScript");
qs("#resultReplay .words")?.addClass("cursiveScript");
} else {
wordsEl.removeClass("withLigatures");
qs("#resultWordsHistory .words")?.removeClass("withLigatures");
qs("#resultReplay .words")?.removeClass("withLigatures");
wordsEl.removeClass("cursiveScript");
qs("#resultWordsHistory .words")?.removeClass("cursiveScript");
qs("#resultReplay .words")?.removeClass("cursiveScript");
}
}

Expand Down Expand Up @@ -2083,7 +2083,7 @@ configEvent.subscribe(({ key, newValue }) => {
) {
if (key !== "fontFamily") updateWordWrapperClasses();
if (["typedEffect", "fontFamily", "fontSize"].includes(key)) {
Ligatures.update(key, wordsEl);
Cursive.update(key, wordsEl);
}
}
if (["tapeMode", "tapeMargin"].includes(key)) {
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/ts/test/words-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ type GenerateWordsReturn = {
hasTab: boolean;
hasNewline: boolean;
allRightToLeft?: boolean;
allLigatures?: boolean;
allCursiveScript?: boolean;
};

let previousRandomQuote: QuoteWithTextSplit | null = null;
Expand All @@ -625,7 +625,7 @@ export async function generateWords(
hasTab: false,
hasNewline: false,
allRightToLeft: language.rightToLeft,
allLigatures: language.ligatures ?? false,
allCursiveScript: language.cursiveScript ?? false,
};

isCurrentlyUsingFunboxSection = isFunboxActiveWithFunction("pullSection");
Expand Down Expand Up @@ -661,10 +661,10 @@ export async function generateWords(
if (result instanceof PolyglotWordset) {
const polyglotResult = result;
currentWordset = polyglotResult;
// set allLigatures if any language in languageProperties has ligatures true
ret.allLigatures = Array.from(
// set allCursiveScript if any language in languageProperties has cursiveScript: true
ret.allCursiveScript = Array.from(
polyglotResult.languageProperties.values(),
).some((props) => !!props.ligatures);
).some((props) => !!props.cursiveScript);
} else {
currentWordset = result;
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/utils/json-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export async function getLayout(layoutName: string): Promise<LayoutObject> {
// used for polyglot wordset language-specific properties
export type LanguageProperties = Pick<
LanguageObject,
"noLazyMode" | "ligatures" | "rightToLeft" | "additionalAccents"
"noLazyMode" | "cursiveScript" | "rightToLeft" | "additionalAccents"
>;

let currentLanguage: LanguageObject;
Expand Down
2 changes: 1 addition & 1 deletion frontend/static/funbox/backwards.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
direction: ltr;
}

#words.withLigatures .word {
#words.cursiveScript .word {
unicode-bidi: bidi-override;
}
2 changes: 1 addition & 1 deletion frontend/static/funbox/choo_choo.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
}

#words letter,
#words.withLigatures .word letter {
#words.cursiveScript .word letter {
display: inline-block;
}
2 changes: 1 addition & 1 deletion frontend/static/funbox/earthquake.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
}

#words letter,
#words.withLigatures .word letter {
#words.cursiveScript .word letter {
display: inline-block;
}
1 change: 0 additions & 1 deletion frontend/static/languages/amharic.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "amharic",
"ligatures": false,
"bcp47": "am-ET",
"words": [
"እግዚአብሔር",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/amharic_1k.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "amharic_1k",
"ligatures": false,
"bcp47": "am-ET",
"words": [
"መለየት",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/amharic_5k.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "amharic_5k",
"ligatures": false,
"bcp47": "am-ET",
"words": [
"ሙዚቀኝነት",
Expand Down
2 changes: 1 addition & 1 deletion frontend/static/languages/arabic.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "arabic",
"rightToLeft": true,
"ligatures": true,
"cursiveScript": true,
"bcp47": "ar-SA",
"words": [
"أَتَمَنَّى",
Expand Down
2 changes: 1 addition & 1 deletion frontend/static/languages/arabic_10k.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "arabic_10k",
"rightToLeft": true,
"ligatures": true,
"cursiveScript": true,
"bcp47": "ar-SA",
"words": [
" اِكْتَشَفَ",
Expand Down
2 changes: 1 addition & 1 deletion frontend/static/languages/arabic_egypt.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "arabic_egypt",
"rightToLeft": true,
"ligatures": true,
"cursiveScript": true,
"bcp47": "ar-EG",
"words": [
"ازيك",
Expand Down
2 changes: 1 addition & 1 deletion frontend/static/languages/arabic_egypt_1k.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "arabic_egypt_1k",
"rightToLeft": true,
"ligatures": true,
"cursiveScript": true,
"bcp47": "ar-EG",
"words": [
"بلاش",
Expand Down
2 changes: 1 addition & 1 deletion frontend/static/languages/arabic_morocco.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "arabic_morocco",
"rightToLeft": true,
"ligatures": true,
"cursiveScript": true,
"orderedByFrequency": false,
"bcp47": "ar-MA",
"words": [
Expand Down
2 changes: 1 addition & 1 deletion frontend/static/languages/bangla.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bangla",
"ligatures": true,
"cursiveScript": true,
"noLazyMode": true,
"bcp47": "bn-BD",
"words": [
Expand Down
2 changes: 1 addition & 1 deletion frontend/static/languages/bangla_10k.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bangla_10k",
"ligatures": true,
"cursiveScript": true,
"noLazyMode": true,
"bcp47": "bn_BD",
"words": [
Expand Down
Loading
Loading