Skip to content

Commit

Permalink
Merge pull request #210 from nepalcodes/more-languages
Browse files Browse the repository at this point in the history
added sanskrit and nepali
  • Loading branch information
NancyAanchal authored Aug 15, 2024
2 parents 0022665 + e528987 commit bb5942b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
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 @@ -45,6 +45,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 @@ -2,6 +2,8 @@ const GOOGLE_TRANSLATE_API_KEY = import.meta.env.VITE_GOOGLE_TRANSLATE_API_KEY;

const languageCodes: { [key: string]: string } = {
maithili: "mai",
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 @@ -58,7 +58,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

0 comments on commit bb5942b

Please sign in to comment.