MCPcopy Create free account
hub / github.com/a7medev/react-native-ml-kit / App

Function App

translate-text/example/App.js:7–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5} from '@react-native-ml-kit/translate-text';
6
7const App = () => {
8 const [text, setText] = useState('');
9
10 const handlePress = () => {
11 TranslateText.translate({
12 text,
13 sourceLanguage: TranslateLanguage.ENGLISH,
14 targetLanguage: TranslateLanguage.SPANISH,
15 downloadModelIfNeeded: true,
16 })
17 .then(result => {
18 Alert.alert(result);
19 })
20 .catch(error => {
21 Alert.alert(error);
22 });
23 };
24
25 return (
26 <View style={styles.container}>
27 <Text style={styles.heading}>Enter text to translate</Text>
28 <TextInput
29 placeholder="Enter text here"
30 multiline
31 textAlignVertical="top"
32 style={styles.input}
33 value={text}
34 onChangeText={_text => setText(_text)}
35 />
36 <Button title="Translate into Spanish" onPress={handlePress} />
37 </View>
38 );
39};
40
41const styles = StyleSheet.create({
42 container: {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected