@bsky.app/expo-guess-language
An Expo module for language detection using native platform APIs, with a JavaScript fallback.
Platform support
| Platform | Backend | Notes |
|---|---|---|
| iOS | NaturalLanguage | Always available (iOS 15.1+) |
| Android | ML Kit Language ID | Requires Google Play Services |
| Android (no Play Services) | lande | Automatic JS fallback |
| Web | lande | JS-only |
Installation
npx expo install @bsky.app/expo-guess-language
For bare React Native projects, run npx pod-install after installing.
Usage
Async
import { guessLanguageAsync } from "@bsky.app/expo-guess-language";
const results = await guessLanguageAsync("Hello, world!");
// [{ language: "en", confidence: 0.98 }, ...]
Sync
import { guessLanguageSync } from "@bsky.app/expo-guess-language";
const results = guessLanguageSync("Hello, world!");
// [{ language: "en", confidence: 0.98 }, ...]
On iOS, guessLanguageSync uses the native NaturalLanguage framework. On Android and web, it uses the lande JS library.
Options
const results = await guessLanguageAsync("Bonjour le monde!", {
maxResults: 3, // default: 10
});
Types
type LanguageResult = {
language: string; // BCP-47 code ("en", "fr", "ja", ...)
confidence: number; // 0 to 1
};
type GuessLanguageOptions = {
maxResults?: number; // default 10
};
License
MIT