()
| 3 | import IdentifyLanguages from '@react-native-ml-kit/identify-languages'; |
| 4 | |
| 5 | const App = () => { |
| 6 | const [text, setText] = useState(''); |
| 7 | const [lang, setLang] = useState(''); |
| 8 | |
| 9 | useEffect(() => { |
| 10 | IdentifyLanguages.identify(text).then(setLang).catch(console.error); |
| 11 | IdentifyLanguages.identifyPossible(text) |
| 12 | .then(identifiedLangs => { |
| 13 | console.log(identifiedLangs); |
| 14 | }) |
| 15 | .catch(console.error); |
| 16 | }, [text]); |
| 17 | |
| 18 | return ( |
| 19 | <View style={styles.container}> |
| 20 | <Text style={styles.heading}>Enter text to detect language</Text> |
| 21 | <TextInput |
| 22 | placeholder="Enter text here" |
| 23 | multiline |
| 24 | textAlignVertical="top" |
| 25 | style={styles.input} |
| 26 | value={text} |
| 27 | onChangeText={_text => setText(_text)} |
| 28 | /> |
| 29 | {lang ? ( |
| 30 | <Text style={styles.heading}>Language Code is: {lang}</Text> |
| 31 | ) : null} |
| 32 | </View> |
| 33 | ); |
| 34 | }; |
| 35 | |
| 36 | const styles = StyleSheet.create({ |
| 37 | container: { |
nothing calls this directly
no test coverage detected