Google language support
Project description
google-language-support
A Python package providing comprehensive language code support for Google services.
Installation
pip install google-language-support
Usage
from google_language_support import LanguageCodes
# Access language codes
print(LanguageCodes.ENGLISH) # "en"
print(LanguageCodes.SPANISH) # "es"
print(LanguageCodes.CHINESE_SIMPLIFIED) # "zh-CN"
# Convert to human-readable names
print(LanguageCodes.ENGLISH.to_instruction()) # "English"
print(LanguageCodes.CHINESE_SIMPLIFIED.to_instruction()) # "Chinese, Simplified, China"
print(LanguageCodes.FRENCH_CA.to_instruction()) # "French, Canada"
# Convert from common language names (NEW!)
print(LanguageCodes.from_common_name("English")) # LanguageCodes.ENGLISH
print(LanguageCodes.from_common_name("spanish")) # LanguageCodes.SPANISH (case-insensitive)
print(LanguageCodes.from_common_name("zh-CN")) # LanguageCodes.CHINESE_SIMPLIFIED
print(LanguageCodes.from_common_name("Mandarin")) # LanguageCodes.CHINESE_SIMPLIFIED_2
print(LanguageCodes.from_common_name("Deutsch")) # LanguageCodes.GERMAN
# Supports various input formats:
print(LanguageCodes.from_common_name("Brazilian Portuguese")) # LanguageCodes.PORTUGUESE_BR
print(LanguageCodes.from_common_name("Simplified Chinese")) # LanguageCodes.CHINESE_SIMPLIFIED
print(LanguageCodes.from_common_name("Bahasa Indonesia")) # LanguageCodes.INDONESIAN
# Fuzzy matching for typos
print(LanguageCodes.from_common_name("Englsh")) # LanguageCodes.ENGLISH (missing 'i')
print(LanguageCodes.from_common_name("Frech")) # LanguageCodes.FRENCH (missing 'n')
# Safe version that returns None instead of raising exception
result = LanguageCodes.from_might_common_name("Unknown Language")
print(result) # None
Features
- 230+ language codes - Comprehensive coverage of languages supported by Google services
- Human-readable names - Convert language codes to readable format with
to_instruction() - Flexible input parsing - Convert from various language name formats with
from_common_name() - Regional variants - Support for region-specific language codes (e.g.,
zh-CN,fr-CA,pt-BR) - Multiple aliases - Some languages have multiple code representations for compatibility
- Fuzzy matching - Handles typos and variations in language names (80% similarity threshold)
- Case-insensitive - Works with any case combination of language names
Supported Input Formats for from_common_name()
- Enum names: "ENGLISH", "SPANISH", "CHINESE_SIMPLIFIED"
- Language codes: "en", "es", "zh-CN", "pt-BR"
- ISO 639-1/639-3 codes: "en"/"eng", "es"/"spa", "fr"/"fra"
- Common variations: "Chinese", "Tagalog", "Ganda", "Sotho"
- Native names: "Mandarin", "Farsi", "Deutsch", "Español", "Français"
- Casual variants: "Brazilian Portuguese", "Canadian French", "American English"
- Cultural references: "Pinyin", "Kanji", "Hangul", "Cyrillic"
- Instruction names: "Chinese, Simplified, China", "Filipino (Tagalog)"
Supported Languages
The package includes language codes for major world languages including:
- European languages (English, Spanish, French, German, etc.)
- Asian languages (Chinese, Japanese, Korean, Hindi, etc.)
- African languages (Swahili, Yoruba, Amharic, etc.)
- Indigenous and regional languages (Quechua, Cherokee, Hawaiian, etc.)
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file google_language_support-0.2.0.tar.gz.
File metadata
- Download URL: google_language_support-0.2.0.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.11.13 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f8de942508a6765e5c5d00226ab49329038c55df361533e51bccfe44b5ddb03
|
|
| MD5 |
746ef32682dbc798c05fb432c924b0ce
|
|
| BLAKE2b-256 |
59896f39727f0e339294c16792bb5af15adef40c93fb0d3d6946a502e0da80bb
|
File details
Details for the file google_language_support-0.2.0-py3-none-any.whl.
File metadata
- Download URL: google_language_support-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.11.13 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d2b0b89ba2f86c489faaf20d7c094ab7477089b7fbaa3fb1e8df04a110711da
|
|
| MD5 |
e325d0ce1fd2bce1c7eb00a1a310fd24
|
|
| BLAKE2b-256 |
631d01977f0f171f36895f2a4a89308b99b84dad3772b272ca28af1a2e2b017f
|