Install franc-all
mainfranc-all via npm.repository·main·Indexed 26 days ago
https://github.com/wooorm/francA language detection library using trigram-based analysis that supports up to 414 languages identified by ISO 639-3 codes. Available as an ESM module for Node.js (14.14+ or 16.0+), Deno, and browsers, as well as a CLI tool. The monorepo includes several packages: franc (187 languages), franc-min (82 languages), franc-all (414 languages), and franc-cli.
franc-all via npm.Depending on your environment, install the appropriate package. Note that the standard franc package is ESM only and supports 187 languages.
esm.sh.esm.sh with the ?bundle query parameter.Available packages:
franc: 187 languages (1M+ speakers).franc-min: 82 languages (8M+ speakers).franc-all: 414 languages (all possible).franc-cli: Command line interface.npm install francInstall the franc package using npm. Note that this package is ESM only. It requires Node.js version 14.14+ or 16.0+.
npm install francInstall franc-all using npm. Note that this package is ESM only. It requires Node.js version 14.14+ or 16.0+.
npm install franc-allInstall the franc-cli command-line interface globally using npm to detect the language of text from your terminal.
npm install franc-cli --globalThe franc-cli allows you to detect the language of a string via the command line. You can provide the string as a positional argument or pipe text from stdin (expects UTF-8).
Basic Usage:
# Detect language from a string argument
$ franc "Alle menslike wesens word vry"
# Detect language from stdin
$ echo "এটি একটি ভাষা একক IBM স্ক্রিপ্ট" | francThe franc package exports franc and francAll. Both functions return ISO 639-3 (three-letter) language codes. If a language cannot be determined, they return 'und'.
franc(value, [options]): Returns the single most probable language code as a string.francAll(value, [options]): Returns an array of language-distance tuples Array<[string, number]> sorted by probability.The franc package supports a wide range of languages identified by ISO 639-3 codes. The following table lists the languages available in this build, their corresponding codes, and approximate speaker counts.
| Code | Name | Speakers |
|---|---|---|
cmn | Mandarin Chinese | 885M |
spa | Spanish | 332M |
eng | English | 322M |
rus | Russian | 288M |
arb | Standard Arabic | 280M |
ben | Bengali | 196M |
hin | Hindi | 182M |
por | Portuguese | 182M |
ind | Indonesian | 140M |
jpn | Japanese | 125M |
fra | French | 124M |
deu | German | 121M |
jav | Javanese (Javanese/Latin) | 76M |
kor | Korean | 75M |
tel | Telugu | 73M |
vie | Vietnamese | 67M |
mar | Marathi | 65M |
ita | Italian | 63M |
tam | Tamil | 62M |
tur | Turkish | 59M |
urd | Urdu | 54M |
guj | Gujarati | 44M |
pol | Polish | 44M |
ukr | Ukrainian | 41M |
kan | Kannada | 38M |
mai | Maithili | 35M |
mal | Malayalam | 34M |
pes | Iranian Persian | 33M |
mya | Burmese | 31M |
swh | Swahili (individual language) | 30M |
sun | Sundanese | 27M |
ron | Romanian | 26M |
pan | Panjabi | 26M |
bho | Bhojpuri | 25M |
amh | Amharic | 23M |
hau | Hausa | 22M |
fuv | Nigerian Fulfulde | 22M |
bos | Bosnian (Cyrillic/Latin) | 21M |
hrv | Croatian | 21M |
nld | Dutch | 21M |
srp | Serbian (Cyrillic/Latin) | 21M |
tha | Thai | 21M |
ckb | Central Kurdish | 20M |
yor | Yoruba | 20M |
uzn | Northern Uzbek (Cyrillic/Latin) | 18M |
zlm | Malay (Arabic/Latin) | 18M |
ibo | Igbo | 17M |
npi | Nepali (individual language) | 16M |
ceb | Cebuano | 15M |
skr | Saraiki | 15M |
tgl | Tagalog | 15M |
hun | Hungarian | 15M |
azj | North Azerbaijani (Cyrillic/Latin) | 14M |
sin | Sinhala | 13M |
koi | Komi-Permyak | 13M |
ell | Modern Greek (1453-) | 12M |
ces | Czech | 12M |
mag | Magahi | 11M |
run | Rundi | 11M |
bel | Belarusian | 10M |
plt | Plateau Malagasy | 10M |
qug | Chimborazo Highland Quichua | 10M |
mad | Madurese | 10M |
nya | Nyanja | 10M |
zyb | Yongbei Zhuang | 10M |
pbu | Northern Pashto | 10M |
kin | Kinyarwanda | 9M |
zul | Zulu | 9M |
bul | Bulgarian | 9M |
swe | Swedish | 9M |
lin | Lingala | 8M |
som | Somali | 8M |
hms | Southern Qiandong Miao | 8M |
hnj | Hmong Njua | 8M |
ilo | Iloko | 8M |
kaz | Kazakh | 8M |
uig | Uighur (Arabic/Latin) | 7M |
hat | Haitian | 7M |
khm | Khmer | 7M |
prs | Dari | 7M |
hil | Hiligaynon | 7M |
sna | Shona | 7M |
tat | Tatar | 7M |
xho | Xhosa | 7M |
hye | Armenian | 7M |
min | Minangkabau | 7M |
afr | Afrikaans | 6M |
lua | Luba-Lulua | 6M |
sat | Santali | 6M |
bod | Tibetan | 6M |
tir | Tigrinya | 6M |
fin | Finnish | 6M |
slk | Slovak | 6M |
tuk | Turkmen (Cyrillic/Latin) | 5M |
dan | Danish | 5M |
nob | Norwegian Bokmål | 5M |
suk | Sukuma | 5M |
als | Tosk Albanian | 5M |
sag | Sango | 5M |
nno | Norwegian Nynorsk | 5M |
heb | Hebrew | 5M |
mos | Mossi | 5M |
tgk | Tajik | 4M |
cat | Catalan | 4M |
sot | Southern Sotho | 4M |
kat | Georgian | 4M |
bcl | Central Bikol | 4M |
glg | Galician | 4M |
lao | Lao | 4M |
lit | Lithuanian | 4M |
umb | Umbundu | 4M |
tsn | Tswana | 4M |
vec | Venetian | 4M |
nso | Pedi | 4M |
ban | Balinese | 4M |
bug | Buginese | 4M |
knc | Central Kanuri | 4M |
kng | Koongo | 3M |
ibb | Ibibio | 3M |
lug | Ganda | 3M |
ace | Achinese | 3M |
bam | Bambara | 3M |
tzm | Central Atlas Tamazight | 3M |
ydd | Eastern Yiddish | 3M |
kmb | Kimbundu | 3M |
lun | Lunda | 3M |
shn | Shan | 3M |
war | Waray (Philippines) | 3M |
dyu | Dyula | 3M |
wol | Wolof | 3M |
kir | Kirghiz | 3M |
nds | Low German | 3M |
fuf | Pular | 3M |
mkd | Macedonian | 3M |
vmw | Makhuwa | 3M |
zgh | Standard Moroccan Tamazight | 2M |
ewe | Ewe | 2M |
khk | Halh Mongolian | 2M |
slv | Slovenian | 2M |
ayr | Central Aymara | 2M |
bem | Bemba (Zambia) | 2M |
emk | Eastern Maninkakan | 2M |
bci | Baoulé | 2M |
bum | Bulu (Cameroon) | 2M |
epo | Esperanto | 2M |
pam | Pampanga | 2M |
tiv | Tiv | 2M |
tpi | Tok Pisin | 2M |
ven | Venda | 2M |
ssw | Swati | 2M |
nyn | Nyankole | 2M |
kbd | Kabardian | 2M |
iii | Sichuan Yi | 2M |
yao | Yao | 2M |
lvs | Standard Latvian | 2M |
quz | Cusco Quechua | 2M |
src | Logudorese Sardinian | 2M |
rup | Macedo-Romanian | 2M |
sco | Scots | 2M |
tso | Tsonga | 2M |
men | Mende (Sierra Leone) | 1M |
fon | Fon | 1M |
nhn | Central Nahuatl | 1M |
dip | Northeastern Dinka | 1M |
kde | Makonde | 1M |
kbp | Kabiyè | 1M |
tem | Timne | 1M |
toi | Tonga (Zambia) | 1M |
ekk | Standard Estonian | 1M |
snk | Soninke | 1M |
cjk | Chokwe | 1M |
ada | Adangme | 1M |
aii | Assyrian Neo-Aramaic | 1M |
quy | Ayacucho Quechua | 1M |
rmn | Balkan Romani | 1M |
bin | Bini | 1M |
gaa | Ga | 1M |
ndo | Ndonga | 1M |
franc-all package includes a comprehensive dataset of languages. The data is represented by ISO 639-3 codes, language names, and approximate speaker counts (or data weight). This allows for more exhaustive language detection compared to the standard franc package.The franc-all package supports a wide range of languages identified by ISO 639-3 codes. Below is a sample of the supported languages and their approximate speaker counts:
| Code | Name | Speakers |
|---|---|---|
cmn | Mandarin Chinese | 885M |
spa | Spanish | 332M |
eng | English | 322M |
rus | Russian | 288M |
arb | Standard Arabic | 280M |
ben | Bengali | 196M |
hin | Hindi | 182M |
por | Portuguese | 182M |
ind | Indonesian | 140M |
jpn | Japanese | 125M |
fra | French | 124M |
deu | German | 121M |
kor | Korean | 75M |
vie | Vietnamese | 67M |
ita | Italian | 63M |
tur | Turkish | 59M |
pol | Polish | 44M |
ukr | Ukrainian | 41M |
tha | Thai | 21M |
hun | Hungarian | 15M |
swe | Swedish | 9M |
fin | Finnish | 6M |
dan | Danish | 5M |
heb | Hebrew | 5M |
cat | Catalan | 4M |
lit | Lithuanian | 4M |
lav | Lao | 4M |
nor | Norwegian | 5M |
(Note: This is a partial list. The full dataset includes many more languages and variations, such as different scripts for Bosnian, Serbian, and Uzbek.)
Both franc and francAll accept an optional Options object to refine detection:
only: An array of language codes to allow (e.g., ['por', 'spa']).ignore: An array of language codes to exclude.minLength: The minimum string length required for detection (defaults to 10).