Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added sanskrit and nepali #210

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions nepalingo-web/src/hooks/Langauge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export const Languages = {
Newari: "newari",
Tajpuriya: "tajpuriya",
Maithili: "maithili",
Sanskrit: "sanskrit",
Nepali: "nepali",
} as const;

type LanguageContextProps = {
Expand Down
4 changes: 4 additions & 0 deletions nepalingo-web/src/hooks/useDictionary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ async function getFetcherByLanguage(
return await getTajpuriyaWord(word);
case "Maithili":
return await getGTranslate("maithili", word);
case "Sanskrit":
return await getGTranslate("sanskrit", word);
case "Nepali":
return await getGTranslate("nepali", word);

default:
throw new Error(`Language ${language} not supported`);
Expand Down
2 changes: 2 additions & 0 deletions nepalingo-web/src/lib/getGTranslate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const GOOGLE_TRANSLATE_API_KEY = import.meta.env.VITE_GOOGLE_TRANSLATE_API_KEY;
const languageCodes: { [key: string]: string } = {
maithili: "mai",
newari: "new",
sanskrit: "sa",
nepali: "ne",
};

export const getGTranslate = async (
Expand Down
7 changes: 6 additions & 1 deletion nepalingo-web/src/lib/getNextWord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ export function* wordGenerator(words: string[]) {

export async function getNextWord(language: string) {
let words: string[] = [];
if (language === "Newari" || language === "Maithili") {
if (
language === "Newari" ||
language === "Maithili" ||
language === "Sanskrit" ||
language === "Nepali"
) {
words = newariWords;
} else if (language === "Tajpuriya") {
words = await getTajpuriyaWords();
Expand Down
Loading