Skip to main content

Django models and importers for Unicode CLDR data

Project description

django-cldr

A Django application for importing and managing Unicode CLDR (Common Locale Data Repository) data.

Provides models for territories, languages, scripts, currencies, subdivisions, and their localized names, plus number and date/time formatting patterns across hundreds of locales.

Features

  • Territories: ISO 3166-1 countries and UN M.49 regions with GDP, literacy, and population data
  • Languages & Scripts: BCP47 language codes and ISO 15924 script codes with usage data
  • Currencies: ISO 4217 currency codes with formatting rules and historical territory usage
  • Subdivisions: Administrative subdivisions (states, provinces, etc.)
  • Localized Names: Translated names for territories, languages, scripts, currencies, and subdivisions across 700+ locales
  • Number Formatting: Locale-specific number symbols and patterns (decimal, percent, currency, scientific)
  • Date/Time Formatting: Locale-specific date, time, and datetime patterns with localized month, day, and timezone names
  • Supplemental Data: Week preferences, measurement systems, numbering systems, calendar preferences, plural rules, and more

Requirements

  • Python 3.10+
  • Django 4.2+
  • PostgreSQL (recommended)

Installation

pip install django-cldr

Add to your INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    'cldr',
]

Run migrations:

python manage.py migrate cldr

Quick Start

Import CLDR data:

# Import core data (territories, languages, currencies, etc.)
python manage.py cldr_import --import=core

# Import localized names
python manage.py cldr_import --import=names

# Import number formatting data
python manage.py cldr_import --import=numbers

# Import date/time formatting data
python manage.py cldr_import --import=dates

# Import subdivisions
python manage.py cldr_import --import=subdivisions

# Import everything
python manage.py cldr_import --import=all

Configuration

Optional settings in settings.py:

# CLDR version to download (default: 46.0.0)
CLDR_VERSION = '46.0.0'

# Locales to import for localized data
# Use a list of locale codes, or "modern" for ~80 most-used locales
CLDR_LOCALES = ['en']  # default

# Cache directory for downloaded CLDR JSON files
CLDR_DATA_DIR = '/path/to/cldr/data'

Usage Examples

from cldr.models import Territory, Language, Currency, LocalizedName

# Get a territory
usa = Territory.objects.get(code='US')

# Get languages spoken in a territory
from cldr.models import LanguageTerritory
languages = LanguageTerritory.objects.filter(territory=usa)

# Get localized territory name
localized = LocalizedName.objects.get(
    territory__code='JP',
    locale='fr',
)
print(localized.name)  # "Japon"

# Get number formatting symbols for a locale
from cldr.models import NumberSymbols
symbols = NumberSymbols.objects.get(locale='de')
print(symbols.decimal)  # ","
print(symbols.group)    # "."

# Get currency display names
from cldr.models import CurrencyDisplayName
names = CurrencyDisplayName.objects.filter(
    currency__code='EUR',
    locale='en',
)

Models

Core Supplemental Data

  • Territory - Countries and regions with metadata
  • Language - BCP47 language codes
  • Script - ISO 15924 writing system codes
  • Currency - ISO 4217 currency codes
  • LanguageTerritory - Languages spoken per territory
  • TerritoryCurrency - Historical currency usage per territory
  • TerritoryContainment - Parent-child territory relationships
  • CodeMapping - Maps between alpha-2, alpha-3, numeric, and FIPS codes
  • WeekData - Week preferences per territory
  • MeasurementSystem - Measurement and paper size preferences
  • NumberingSystem - Numbering systems (Latin, Arabic-Indic, etc.)
  • LikelySubtag - Locale inference rules
  • PluralRule - Cardinal and ordinal plural rules
  • CalendarPreference - Preferred calendar types

Subdivisions

  • Subdivision - Administrative subdivisions

Localized Data

  • LocalizedName - Translated names across locales
  • NumberSymbols - Number formatting symbols per locale
  • NumberPattern - Number formatting patterns (ICU syntax)
  • CurrencyDisplayName - Localized currency names with plural forms
  • DateTimePattern - Date/time formatting patterns per locale
  • MonthName - Localized month names
  • DayName - Localized day-of-week names
  • TimezoneName - Localized timezone display names

Data Source

Data is sourced from the Unicode CLDR project via npm packages published by the Unicode Consortium. The CLDR data is licensed under the Unicode License.

Disclaimer

This project is not affiliated with, endorsed by, or associated with the Unicode Consortium or the CLDR project. It is an independent, third-party Django integration that consumes publicly available CLDR data.

License

MIT License - see LICENSE for details.

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

django_cldr-0.1.0.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

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

django_cldr-0.1.0-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file django_cldr-0.1.0.tar.gz.

File metadata

  • Download URL: django_cldr-0.1.0.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_cldr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dcbc96512f96ff7a803a327dfd7586246a2d012d09e77983f84ac09ec4533572
MD5 d0b07250607fe57e10393b0df1c963cb
BLAKE2b-256 996ed405e3233c9cf751e16bc0df616d7737444fab802492124962c94c2cd208

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_cldr-0.1.0.tar.gz:

Publisher: publish.yml on arthanson/django-cldr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_cldr-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_cldr-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_cldr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7b604a5459855c9584286dedfde2c78e46281f55752c0a42e8eeb45fe0af15b
MD5 22cf4f46b2a7cd2ff0ebdf096bbc03f4
BLAKE2b-256 a2be277488f10e9bbff9ad84c96324c11aa7235095b9809147aa63e2ef83650b

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_cldr-0.1.0-py3-none-any.whl:

Publisher: publish.yml on arthanson/django-cldr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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