Skip to content

Commit

Permalink
chore(web): remove-chinese-language
Browse files Browse the repository at this point in the history
  • Loading branch information
Harman-singh-waraich committed Dec 2, 2024
1 parent 246c26a commit e023c06
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 2 additions & 3 deletions web/src/components/TranslateDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ const Langs: { value: SupportedLangs; text: string }[] = [
{ text: "Spanish", value: "es" },
{ text: "Hindi", value: "hi" },
{ text: "Japanese", value: "ja" },
{ text: "Chinese", value: "zh" },
{ text: "Korean", value: "ko" },
{ text: "French", value: "fr" },
];

const TranslateDropdown: React.FC = () => {
const { setLang } = useTranslate();
const { currentLang, setLang } = useTranslate();
return (
<DropdownSelect
smallButton
Expand All @@ -24,7 +23,7 @@ const TranslateDropdown: React.FC = () => {
value: range.value,
text: range.text,
}))}
defaultValue={"en"}
defaultValue={currentLang}
callback={(val) => {
setLang(val as SupportedLangs);
}}
Expand Down
8 changes: 5 additions & 3 deletions web/src/context/TranslateProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { createContext, useCallback, useContext, useEffect, useMemo } fro

import { useLocalStorage } from "hooks/useLocalStorage";

export type SupportedLangs = "en" | "es" | "zh" | "fr" | "hi" | "ko" | "ja";
export type SupportedLangs = "en" | "es" | "fr" | "hi" | "ko" | "ja";

interface ITranslate {
currentLang: SupportedLangs;
Expand Down Expand Up @@ -33,7 +33,7 @@ export const TranslateProvider: React.FC<{ children: React.ReactNode }> = ({ chi
new window.google.translate.TranslateElement(
{
pageLanguage: "en",
includedLanguages: "en,es,hi,ja,zh,fr,ko",
includedLanguages: "en,es,hi,ja,fr,ko",
},
"google_translate_element"
);
Expand All @@ -53,7 +53,9 @@ export const TranslateProvider: React.FC<{ children: React.ReactNode }> = ({ chi
const select = document.querySelector(".goog-te-combo") as HTMLSelectElement;
if (select) {
select.value = cValue;
select.dispatchEvent(new Event("change"));

select.dispatchEvent(new Event("change", { bubbles: true }));
select.click();
}
}
},
Expand Down

0 comments on commit e023c06

Please sign in to comment.