spacy-language-detection
Fully customizable language detection for spaCy pipeline
What it is and what it does
spacy_language_detection is a spaCy pipeline component that detects the language of text at both document and sentence level. It wraps langdetect under the hood and exposes language predictions as custom attributes (doc._.language and span._.language) on spaCy Doc and Span objects. The package was forked from spacy-langdetect to fix a seed problem and add spaCy 3.0 support.
The component is fully customizable: you can replace the default langdetect detector with your own language detection function (e.g., googletrans or pycld2) by passing a callable to the LanguageDetector constructor. This makes it useful for pipelines where you need language identification as a preprocessing or filtering step, or where you want to swap detection backends without rewriting integration code.
Use it for:
- Filter or route multilingual documents to language-specific NLP pipelines based on detected language.
- Identify language switches within a document to handle code-switching or mixed-language text.
- Preprocess text corpora to separate documents by language before applying language-specific models.
- Add language metadata to spaCy Doc objects for downstream analysis or logging.
- Integrate a custom language detector (e.g., from an external API) into a spaCy workflow.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds language detection to spaCy pipelines at document and sentence level, using langdetect by default but accepting custom detection functions.
No. The package is abandoned (last update 2021-09-08, 1801 days ago) with no maintenance signal. While it has low install friction and no known vulnerabilities, the lack of updates means it may break with newer spaCy versions or Python releases. If you need language detection in spaCy, consider maintaining a fork or using a more actively maintained alternative.
Install
spacy-language-detection on PyPI
pip
pip install spacy-language-detectionuv
uv add spacy-language-detectionpoetry
poetry add spacy-language-detectionInstalling spacy-language-detection
Before you install
Low install friction with just two runtime dependencies (spacy and langdetect). However, the package is abandoned—last commit was 2021-09-08 and no updates since. Use only if you need this specific functionality and are comfortable maintaining a fork yourself.
License in practice
Licensed under LGPLv3 (copyleft). You must disclose source code and license any derivative work under the same terms if you distribute it; internal use has no obligation.
Quickstart
import spacy
from spacy.language import Language
from spacy_language_detection import LanguageDetector
def get_lang_detector(nlp, name):
return LanguageDetector(seed=42)
nlp = spacy.load("en_core_web_sm")
Language.factory("language_detector", func=get_lang_detector)
nlp.add_pipe('language_detector', last=True)
doc = nlp("This is English text.")
print(doc._.language)
Requires a spaCy model to be installed separately (e.g., spacy download en_core_web_sm).
Verify before relying
- Accuracy and performance of langdetect on modern language distributions and edge cases.
- Compatibility with spaCy versions released after 2021-09-08.
- Whether the seed-fixing fork resolves the original spacy-langdetect randomness issue completely.
Package facts
| License | LGPLv3 (copyleft) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — spacy, langdetect |
| Maintenance | abandoned — 1,801 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 992,917/month — #4,557 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: spacy_language_detection-0.2.1-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
gibberish-detectorDetects whether strings are gibberish or valid…
permissive · top 15,000 on PyPI
langdetectDetects the language of text input, supporting…
permissive · top 5,000 on PyPI
negspacyAdds negation detection to spaCy pipelines…
permissive · top 15,000 on PyPI
pycld2Detects the language of text using Google's…
permissive · top 15,000 on PyPI
spacyspaCy is an industrial-strength NLP library…
permissive · top 1,000 on PyPI
lingua-language-detectorDetects which language a text is written in,…
permissive · top 5,000 on PyPI
date-spacyAdds a spaCy pipeline component that identifies…
permissive · top 15,000 on PyPI
fasttext-langdetectIdentifies the language of UTF-8 text using…
permissive · top 15,000 on PyPI
vokativConverts Czech given names and surnames into…
permissive · top 15,000 on PyPI
spanishconjugatorConjugates Spanish verbs by tense, mood, and…
permissive · top 15,000 on PyPI