import AsyncStorage from '@react-native-async-storage/async-storage'; import { CachedTranslator } from "@/app/i18n/api" import { longLang } from "@/app/i18n/lang" import { useEffect, useRef, useState } from "react" import { Button } from "react-native" type ISpeakButtonProps = { country: string, language: string, } function iSpeak(language : string) { return `I speak ${longLang(language)}.` } async function iSpeakTr(targetLang : string, sourceLang = "en") { const sourceStr = iSpeak(targetLang) const translator = new CachedTranslator(sourceLang, targetLang); return await translator.translate(sourceStr) } const ISpeakButton = (props : ISpeakButtonProps) => { const [title, setTitle] = useState(""); useEffect(() => { async function () { setTitle(await iSpeakTr(props.language) as string); } }, []); } export default ISpeakButton;