diff --git a/web/src/components/TranslateDropdown.tsx b/web/src/components/TranslateDropdown.tsx index 9ca5a7ab1..c23b57308 100644 --- a/web/src/components/TranslateDropdown.tsx +++ b/web/src/components/TranslateDropdown.tsx @@ -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 ( { value: range.value, text: range.text, }))} - defaultValue={"en"} + defaultValue={currentLang} callback={(val) => { setLang(val as SupportedLangs); }} diff --git a/web/src/context/TranslateProvider.tsx b/web/src/context/TranslateProvider.tsx index f5cd8b24c..280a83db7 100644 --- a/web/src/context/TranslateProvider.tsx +++ b/web/src/context/TranslateProvider.tsx @@ -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; @@ -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" ); @@ -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(); } } },