Skip to main content

python-intl

A small library using PyICU to provide a Python API similar to what the Intl JavaScript API provides. It is not meant to fully behave the same, but instead be close enough so the "same" code works on JavaScript and Python, with similar results.

Status: This is very much work in progress.

Note: There are a lot of tests running the Python implementation against the JavaScript one and comparing the results. In general things should be pretty stable there. Still there are some cases with known differences. Also note that results depend on the ICU version you have installed on your machine.

General notes about the Python adaption

All names will be using the Python style rules. This means instead of formatToParts a method will be called format_to_parts. Also a dictionary key like dayPeriod will be named day_period. Python uses snake case, let's stick to this.

Instead of passing around undefined objects like in JavaScript we want to use well defined and typed dataclasses. This for example is true for the Intl.DateTimeFormat format options, you can use DateTimeFormatOptions as a clean representation of those. Using a dictionary (which behaves the most like those JavaScript objects) is still fine and will automatically converted, as seen in the examples here.

Many objects like for example the DateTimeFormatOptions provide methods to convert their Python representation to a JavaScript compatible JSON format by returning a dict using the JavaScript naming. You can use the to_json method for this.

For example:

import python_intl as Intl

Intl.DateTimeFormatOptions(time_zone_name="short_offset").to_json()
# Will return: {'timeZoneName': 'shortOffset'}

Available Intl classes

Intl.DateTimeFormat

Example usage

import datetime as dt
import python_intl as Intl

# Format a datetime
datetime = dt.datetime(2026, 8, 15)
formatter = Intl.DateTimeFormat("de-DE", {"year": "numeric", "month": "2-digit", "day": "2-digit"})
formatter.format(datetime)
# Result = "15.08.2026"

# Format a datetime range
datetime_till = dt.datetime(2026, 9, 7)
formatter.format_range(datetime, datetime_till)
# Result = "15.08. – 07.09.2026"

Compatibility

Method Status Python name
DateTimeFormat.format
DateTimeFormat.formatToParts DateTimeFormat.format_to_parts
DateTimeFormat.supportedLocalesOf
DateTimeFormat.formatRange DateTimeFormat.format_range
DateTimeFormat.formatRangeToParts DateTimeFormat.format_range_to_parts
DateTimeFormat.resolvedOptions

Intl.Collator

Compatibility

Method Status Python name
Collator.compare

Note: Not all options are currently supported.

Installation

Be sure to be able to install PyICU, see the installation docs there: https://gitlab.pyicu.org/main/pyicu#installing-pyicu

Hint: I mainly did run into issues with pkg-config not finding the ICU library, setting PKG_CONFIG_PATH accordingly helps most of the time I guess.

When this is done you should be able to install python-intl using any package manager, like pip install python-intl or uv add python-intl.

Download files

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

Source Distribution

python_intl-0.6.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

python_intl-0.6.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file python_intl-0.6.0.tar.gz.

File metadata

  • Download URL: python_intl-0.6.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_intl-0.6.0.tar.gz
Algorithm Hash digest
SHA256 9b357b3aff6109cc9f3c8c25a8f1c2bcad8aaf7b0fa139dae7fae8684e525f08
MD5 558a8e0e67ee7813c8b6b6ff3f8a91ce
BLAKE2b-256 b3212ed9b83a6def3e7d182275c6f9aadd6374638905ef5b0955592c4c7f3fe5

See more details on using hashes here.

File details

Details for the file python_intl-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: python_intl-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_intl-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b5c716806600620bf0bb2a7bc9b03cebb2403798340b59478d577814c3c7c71
MD5 c85d4652d89b2d8c5669afd4ade9d973
BLAKE2b-256 57ca0e7c558bb7cde952f1a37f58e1bbad8f732dab606a421ca2722d69ea01b9

See more details on using hashes here.

Release history Release notifications | RSS feed

0.8.0

2 files

0.7.1

2 files

This release

0.6.0 This release

2 files

0.5.0

2 files

0.4.0

2 files

0.3.1

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page