--- id: pycld2 version: "0.42" license: Apache2 license_treatment: permissive maintenance: aging --- # pycld2 — Python bindings around Google Chromium's embedded compact language detection library (CLD2) License: permissive · Maintenance: aging · Downloads: 774.2K/mo ## What it is and what it does pycld2 is a Python wrapper around Google's Compact Language Detect 2 (CLD2), a C++ library that identifies the language of text. It consolidates the upstream CLD2 library with its bindings into a single pip-installable package, supporting detection across over 165 languages by default. The package exposes a single primary function, `detect()`, which takes UTF-8 text (as str or bytes) and returns a reliability flag, byte count, and a list of detected languages with confidence scores. Optionally, it can return byte-range vectors showing which language was detected in which part of the input, and accepts hints (top-level domain, language preference, encoding) to influence detection. The package is built on precompiled wheels for Python 3.8–3.12 across macOS, Linux, and Windows, eliminating the need to compile C++ locally in most cases. It has no runtime dependencies beyond the C++ bindings. The API is minimal and straightforward: call `detect()` with your text and optional parameters, and receive structured results. It is useful for applications that need fast, lightweight language identification without the overhead of neural models, though the aging maintenance status (last release 504 days ago) means it may not have been tested against the very latest Python patch releases. Use it for: - Automatically categorize user-generated content by language in multilingual web applications or content management systems. - Pre-process text corpora for natural language processing pipelines by filtering or routing documents to language-specific models. - Detect language in HTTP requests or HTML documents, using optional hints from domain or HTTP headers to improve accuracy. - Identify the primary language in mixed-language documents and extract byte ranges showing where each language appears. - Triage support tickets or chat messages by language to route them to appropriate language-specific teams or handlers. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Detects the language of text using Google's CLD2 library, supporting over 165 languages and returning reliability scores and byte-range vectors. Yes, if you need lightweight, fast language detection across many languages without external dependencies or neural models. The prebuilt wheels make installation straightforward on common platforms. However, consider the aging maintenance status (last release 504 days ago): verify that it works reliably with your target Python version and that CLD2's detection quality meets your accuracy requirements. If you need state-of-the-art accuracy, CLD3 or neural alternatives may be better; if you need speed and simplicity, pycld2 is a solid choice. ## Install pip install pycld2 uv add pycld2 poetry add pycld2 ## Installing pycld2 Before you install: Medium install friction due to compiled C++ bindings; prebuilt wheels are available for Python 3.8–3.12 on macOS, Linux (x86_64, i686, musl), and Windows. Last release was 504 days ago; the project is aging but the repository remains active. License in practice: Licensed under Apache 2.0 (permissive). Safe for commercial and proprietary use with minimal restrictions; attribution and license inclusion are required. Quickstart: import pycld2 as cld2 isReliable, textBytesFound, details = cld2.detect( "а неправильный формат идентификатора дн назад" ) print(details[0]) # ('RUSSIAN', 'ru', 98, 404.0) Input must be UTF-8 encoded (str or UTF-8 bytes); non-UTF-8 bytes will raise pycld2.error. Verify before relying: - Whether the aging maintenance status (504 days since last release) affects reliability or security for new Python versions beyond 3.12. - Performance characteristics and memory footprint for large-scale batch language detection. - Accuracy comparison with CLD3 or other modern language detection libraries. ## Package facts - License: Apache2 (permissive) - Python support: unspecified - Install friction: medium - Maintenance: aging - Downloads: 774.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags language detection, detect text language, multilingual language identification, cld2 python bindings, compact language detect, identify document language, language recognition, language-detection, multilingual, text-processing [View on SkillFed](https://skillfed.io/packages/pycld2) · [View on PyPI](https://pypi.org/project/pycld2/)