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.3.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.3-py3-none-any.whl (59.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for countrystatecity_translations-1.0.3.tar.gz
Algorithm Hash digest
SHA256 ac858f021122bb248ee4b72de3d0012253184f1f8446edb08edc858bd4480e6f
MD5 fb9185a38d367a4f30f4386d06de0a4a
BLAKE2b-256 f2f00f567eeb1a180e89ced2600da63f32c530bed9ef3b5fd7dedc685a6f15bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for countrystatecity_translations-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 08427ec4bd8f28e65f14ea0e2a068c501f11a5cc6f2c76d2aad717a70fc4b88b
MD5 445f5fc85f3aa2bf5ec927de367c93b4
BLAKE2b-256 f0397b424e49a02bb7dc048b64c0da60ef04cf0cb288bd7f5fc6d95446652dac

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