import { Language } from "@opentranslate/languages" ; import franc from "franc-min" ; const langMap = new Map < string , Language > ( [ [ "eng" , "en" ] , [ "jpn" , "ja" ] , [ "kor" , "ko" ] , [ "cmn" , "zh-CN" ] ] ) ; const options = { minLength : 1 , whitelist : [ ... langMap . keys ( ) ] } ; /**
 * Naive fallback language detection
 */ export function detectLang ( text ) { return langMap . get ( franc ( text , options ) ) || "auto" ; }