Skip to content

Commit

Permalink
fix(word generation): display proper period and numbers for hindi (#5366
Browse files Browse the repository at this point in the history
)
  • Loading branch information
shahnewaz-labib committed May 6, 2024
1 parent 7fd31dc commit e88601d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion frontend/src/ts/test/words-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ export async function punctuateWord(
if (rand <= 0.8) {
if (currentLanguage === "kurdish") {
word += ".";
} else if (currentLanguage === "nepali") {
} else if (
currentLanguage === "nepali" ||
currentLanguage === "hindi"
) {
word += "।";
} else if (
currentLanguage === "japanese" ||
Expand Down Expand Up @@ -864,6 +867,8 @@ export async function getNextWord(
randomWord = Misc.convertNumberToArabic(randomWord);
} else if (Config.language.startsWith("nepali")) {
randomWord = Misc.convertNumberToNepali(randomWord);
} else if (Config.language.startsWith("hindi")) {
randomWord = Misc.convertNumberToHindi(randomWord);
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/ts/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ export function convertNumberToNepali(numString: string): string {
return ret;
}

export function convertNumberToHindi(numString: string): string {
const hindiIndic = "०१२३४५६७८९";
let ret = "";
for (const char of numString) {
ret += hindiIndic[parseInt(char)];
}
return ret;
}

export function findGetParameter(
parameterName: string,
getOverride?: string
Expand Down

0 comments on commit e88601d

Please sign in to comment.