Skip to main content

Type-safe Python package for country name translations across 19 languages with country associations and language codes.

Project description

countrystatecity-translations

PyPI version Python versions

Official Python package for country name translations — 4700+ entries covering 195 countries across 19 languages. Part of the countrystatecity ecosystem.

Installation

pip install countrystatecity-translations

Quick Start

from countrystatecity_translations import (
    get_all_translations,
    get_translations_by_country,
    get_translations_by_language,
    get_translation,
    search_translations,
)

# Get all translation entries
translations = get_all_translations()
# [Translation(countryCode="AF", lang="fr", translation="Afghanistan", ...), ...]

# Get all translations for a country (all 19 languages)
de_translations = get_translations_by_country("DE")
# [Translation(countryCode="DE", lang="fr", translation="Allemagne", ...), ...]

# Get all countries translated into a specific language
french = get_translations_by_language("fr")
# [Translation(lang="fr", translation="Afghanistan", ...), ...]

# Lookup a single translation
t = get_translation("DE", "fr")
# Translation(countryCode="DE", countryName="Germany", lang="fr", translation="Allemagne")

# Search translated names
results = search_translations("Allemagne")

Data Model

class Translation(BaseModel):
    countryCode: str  # ISO2 country code (e.g., "DE")
    countryName: str  # English country name (e.g., "Germany")
    lang: str         # Language code (e.g., "fr")
    translation: str  # Translated country name (e.g., "Allemagne")

Supported Languages

Code Language Code Language
ar Arabic ko Korean
br Breton nl Dutch
de German pl Polish
es Spanish pt Portuguese
fa Persian pt-BR Portuguese (Brazil)
fr French ru Russian
hi Hindi tr Turkish
hr Croatian uk Ukrainian
it Italian zh-CN Chinese (Simplified)
ja Japanese

API Reference

Function Description
get_all_translations() Get all translation entries
get_translations_by_country(code) Get all language translations for a country
get_translations_by_language(lang) Get all countries translated into a language
get_translation(code, lang) Get a single country-language translation
search_translations(query) Search by translated name or English country name

License

ODbL-1.0 — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

countrystatecity_translations-1.0.0.tar.gz (58.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

countrystatecity_translations-1.0.0-py3-none-any.whl (59.1 kB view details)

Uploaded Python 3

File details

Details for the file countrystatecity_translations-1.0.0.tar.gz.

File metadata

File hashes

Hashes for countrystatecity_translations-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2c91e774f58a242322d23ad0cb19f9f3a5cc939a479e3d9e00a065f8a440ca81
MD5 d53c37c24f8278fa941564d018bc4573
BLAKE2b-256 0fde23e0c25cac222f65fb236283f068e512a56dc764f6a6d6f12187e06ff3ce

See more details on using hashes here.

File details

Details for the file countrystatecity_translations-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for countrystatecity_translations-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3e3c1999d7e7f742f2ce2c6b2a6a6c0617c5f0b854a7d7effcf79fe0e6b5bfb
MD5 2c55faecb4a01ce68da40bd4a594856f
BLAKE2b-256 f91ede932aef9296779fa8d27b99c99ee9a8f71db1314279dfad2de7c458a205

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page