-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #154 from nepalcodes/tajpuiya-flahscards
immplemented change language to flahscards and dictionary
- Loading branch information
Showing
8 changed files
with
126 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { DictionaryResponse } from "@/hooks/useDictionary"; | ||
|
||
export async function getTajpuriyaWord( | ||
word: string, | ||
): Promise<DictionaryResponse> { | ||
const wordText = await fetch("./dictionaries/TajpuriyaDictionary.csv") | ||
.then((r) => r.text()) | ||
.catch((error) => { | ||
console.error("Error fetching words:", error); | ||
}); | ||
|
||
if (!wordText) { | ||
throw new Error("Error fetching tajpuriya CSV"); | ||
} | ||
const dictArray = wordText.split("\n"); | ||
|
||
for (const line of dictArray) { | ||
const [englishWord, tajpuriyaWord] = line | ||
.split(",") | ||
.map((word) => word.trim().replace(/(^"|"$)/g, "")); | ||
|
||
if (englishWord.toLowerCase() == word.toLowerCase()) { | ||
return { | ||
language: "tajpuriya", | ||
word: word, | ||
meanings: [ | ||
{ | ||
language: "tajpuriya", | ||
meaningOriginal: tajpuriyaWord, | ||
meaningEn: englishWord, | ||
}, | ||
], | ||
}; | ||
} | ||
} | ||
throw new Error(`Word "${word}" not found in tajpuriya dictionary`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters