Locale-aware number and date formatting.
Minimal formatting utilities. For full ICU support, use thebabellibrary.
i18n.formatting
| Name | Type | Default | Description |
|---|---|---|---|
type
|
|
— | |
qualified_name
|
|
— | |
element_type
|
|
— | |
description
|
|
— | |
source_file
|
|
— | |
line_number
|
|
— | |
is_autodoc
|
|
— | |
autodoc_element
|
|
— | |
_autodoc_template
|
|
— | |
_autodoc_url_path
|
|
— | |
_autodoc_page_type
|
|
— | |
title
|
|
— | |
doc_content_hash
|
|
— |
Symbols on this page
format_number
function
def format_number(value: int | float, locale: str = 'en') -> str
Basic number formatting with locale-appropriate separators.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
value
|
int | float
|
— | |
locale
|
str
|
'en'
|
_add_separator
function
def _add_separator(s: str, sep: str) -> str
Add thousands separator to a string of digits.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
s
|
str
|
— | |
sep
|
str
|
— |
format_date
function
def format_date(value: datetime.date | datetime.datetime, locale: str = 'en', fmt: str = 'short') -> str
Basic date formatting.
Formats:
- short: 2024-03-15
- medium: Mar 15, 2024
- long: March 15, 2024
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
value
|
datetime.date | datetime.datetime
|
— | |
locale
|
str
|
'en'
|
|
fmt
|
str
|
'short'
|
View source · /home/runner/work/chirp/chirp/site/../src/chirp/i18n/formatting.py:1