Skip to content

Commit

Permalink
converted required leftToRight to optional rightToLeft (monkeytypegam…
Browse files Browse the repository at this point in the history
…e#4229)

* converted required leftToRight to optional rightToLeft

* merge straggler

* removed empty lines

* removed empty lines
  • Loading branch information
Miodec authored Apr 26, 2023
1 parent 91b3800 commit 5543aaa
Show file tree
Hide file tree
Showing 283 changed files with 49 additions and 312 deletions.
14 changes: 6 additions & 8 deletions LANGUAGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@ The contents of the file should be as follows:

```
{
"name": "language",
"leftToRight": true,
"ligatures": true,
"bcp47": "es-ES",
"words": [
"words",
]
"name": string,
"rightToLeft": boolean,
"ligatures": 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. `leftToRight` indicates how the language is written. If it is written left to right then put `true`, otherwise put `false`.
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 left to right 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 to `false`. For `bcp47` put your languages [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag). Finally, add your list of words to the `words` field.

In addition to the language file, you need to add your language to the `_groups.json` and `_list.json` files in the same directory. Add the name of the language to the `_groups.json` file like so:
Expand Down
4 changes: 2 additions & 2 deletions frontend/scripts/json-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ function validateLanguages() {
type: "object",
properties: {
name: { type: "string" },
leftToRight: { type: "boolean" },
rightToLeft: { type: "boolean" },
noLazyMode: { type: "boolean" },
bcp47: { type: "string" },
words: {
Expand All @@ -525,7 +525,7 @@ function validateLanguages() {
},
},
},
required: ["name", "leftToRight", "words"],
required: ["name", "words"],
};
let languageFilesAllGood = true;
let languageWordListsAllGood = true;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/ts/test/caret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ export async function updatePosition(): Promise<void> {
] as HTMLElement;

const currentLanguage = await Misc.getCurrentLanguage(Config.language);
const isLanguageLeftToRight = currentLanguage.leftToRight;
const isLanguageRightToLeft = currentLanguage.rightToLeft;
const letterPosLeft =
(currentLetter
? currentLetter.offsetLeft
: previousLetter.offsetLeft + previousLetter.offsetWidth) +
(isLanguageLeftToRight
(!isLanguageRightToLeft
? 0
: currentLetter
? currentLetter.offsetWidth
Expand Down
8 changes: 2 additions & 6 deletions frontend/src/ts/test/test-logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ export async function init(): Promise<void> {
}
}

if (Config.tapeMode !== "off" && !language.leftToRight) {
if (Config.tapeMode !== "off" && !language.rightToLeft) {
Notifications.add("This language does not support tape mode.", 0, {
important: true,
});
Expand Down Expand Up @@ -1173,11 +1173,7 @@ export async function init(): Promise<void> {
}
}
//handle right-to-left languages
if (language.leftToRight) {
TestUI.arrangeCharactersLeftToRight();
} else {
TestUI.arrangeCharactersRightToLeft();
}
TestUI.setRightToLeft(language.rightToLeft);
if (language.ligatures) {
$("#words").addClass("withLigatures");
$("#resultWordsHistory .words").addClass("withLigatures");
Expand Down
20 changes: 10 additions & 10 deletions frontend/src/ts/test/test-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -830,16 +830,16 @@ export function lineJump(currentTop: number): void {
updateWordsHeight();
}

export function arrangeCharactersRightToLeft(): void {
$("#words").addClass("rightToLeftTest");
$("#resultWordsHistory .words").addClass("rightToLeftTest");
$("#resultReplay .words").addClass("rightToLeftTest");
}

export function arrangeCharactersLeftToRight(): void {
$("#words").removeClass("rightToLeftTest");
$("#resultWordsHistory .words").removeClass("rightToLeftTest");
$("#resultReplay .words").removeClass("rightToLeftTest");
export function setRightToLeft(isEnabled: boolean): void {
if (isEnabled) {
$("#words").addClass("rightToLeftTest");
$("#resultWordsHistory .words").addClass("rightToLeftTest");
$("#resultReplay .words").addClass("rightToLeftTest");
} else {
$("#words").removeClass("rightToLeftTest");
$("#resultWordsHistory .words").removeClass("rightToLeftTest");
$("#resultReplay .words").removeClass("rightToLeftTest");
}
}

async function loadWordsHistory(): Promise<boolean> {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ declare namespace MonkeyTypes {

interface LanguageObject {
name: string;
leftToRight: boolean;
rightToLeft: boolean;
noLazyMode?: boolean;
ligatures?: boolean;
orderedByFrequency?: boolean;
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/afrikaans.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "afrikaans",
"leftToRight": true,
"words": [
"die",
"wees",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/afrikaans_10k.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "afrikaans_10k",
"leftToRight": true,
"words": [
"aan",
"aanbetref",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/afrikaans_1k.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "afrikaans_1k",
"leftToRight": true,
"noLazyMode": true,
"words": [
"sterker",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/albanian.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "albanian",
"leftToRight": true,
"words": [
"",
"e",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/albanian_1k.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "albanian_1k",
"leftToRight": true,
"words": [
"I",
"e tij",
Expand Down
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",
"leftToRight": true,
"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,6 +1,6 @@
{
"name": "arabic",
"leftToRight": false,
"rightToLeft": true,
"ligatures": 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,6 +1,6 @@
{
"name": "arabic_10k",
"leftToRight": false,
"rightToLeft": true,
"ligatures": true,
"bcp47": "ar-SA",
"words": [
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/armenian_western.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "armenian_western",
"leftToRight": true,
"bcp47": "hyw",
"words": [
"կանանց",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/armenian_western_1k.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "armenian_western_1k",
"leftToRight": true,
"bcp47": "hyw",
"words": [
"թարգմանուած",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/azerbaijani.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "azerbaijani",
"leftToRight": true,
"bcp47": "az-AZ",
"words": [
"dərs",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/azerbaijani_1k.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "azerbaijani_1k",
"leftToRight": true,
"bcp47": "az-AZ",
"words": [
"dərs",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/bangla.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "bangla",
"leftToRight": true,
"ligatures": true,
"noLazyMode": true,
"bcp47": "bn-BD",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/bangla_10k.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "bangla_10k",
"leftToRight": true,
"ligatures": true,
"noLazyMode": true,
"bcp47": "bn_BD",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/bangla_letters.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "bangla_letters",
"leftToRight": true,
"ligatures": true,
"noLazyMode": true,
"bcp47": "bn-BD",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/belarusian_1k.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "belarusian_1k",
"leftToRight": true,
"noLazyMode": true,
"bcp47": "be-BY",
"words": [
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/bulgarian.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "bulgarian",
"leftToRight": true,
"noLazyMode": true,
"words": [
"а",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/catalan.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "catalan",
"leftToRight": true,
"words": [
"de",
"la",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/catalan_1k.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "catalan_1k",
"leftToRight": true,
"words": [
"de",
"la",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/chinese_traditional.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "chinese_traditional",
"leftToRight": true,
"noLazyMode": true,
"words": [
"安靜",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_arduino.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_arduino",
"leftToRight": true,
"noLazyMode": true,
"words": [
"digitalRead",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_assembly.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_assembly",
"leftToRight": true,
"noLazyMode": true,
"words": [
"AAA",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_bash.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_bash",
"leftToRight": true,
"noLazyMode": true,
"words": [
"ls",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_brainfck.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_brainfck",
"leftToRight": true,
"noLazyMode": true,
"words": [
">",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_c++.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_c++",
"leftToRight": true,
"noLazyMode": true,
"words": [
"alignas",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_c.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_c",
"leftToRight": true,
"noLazyMode": true,
"words": [
"auto",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_csharp.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_csharp",
"leftToRight": true,
"noLazyMode": true,
"words": [
"abstract",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_css.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_css",
"leftToRight": true,
"noLazyMode": true,
"words": [
"background-color",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_dart.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_dart",
"leftToRight": true,
"noLazyMode": true,
"words": [
"()",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_elixir.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_elixir",
"leftToRight": true,
"ligatures": true,
"words": [
"__MODULE__",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_fsharp.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_fsharp",
"leftToRight": true,
"words": [
"abstract",
"and",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_gdscript.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_gdscript",
"leftToRight": true,
"words": [
"var",
"const",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_gdscript_2.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_gdscript_2",
"leftToRight": true,
"words": [
"var",
"const",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_go.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_go",
"leftToRight": true,
"noLazyMode": true,
"words": [
"break",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_haskell.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_haskell",
"leftToRight": true,
"noLazyMode": true,
"words": [
"!",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_html.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_html",
"leftToRight": true,
"noLazyMode": true,
"words": [
"-->",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_java.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_java",
"leftToRight": true,
"noLazyMode": true,
"words": [
"abstract",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_javascript.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_javascript",
"leftToRight": true,
"noLazyMode": true,
"words": [
"this",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_javascript_1k.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_javascript_1k",
"leftToRight": true,
"noLazyMode": true,
"words": [
"var",
Expand Down
1 change: 0 additions & 1 deletion frontend/static/languages/code_julia.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "code_julia",
"leftToRight": true,
"noLazyMode": true,
"words": [
"return",
Expand Down
Loading

0 comments on commit 5543aaa

Please sign in to comment.