Skip to main content

Flask-I18N-Pro

Internationalization for Flask with Cyrillic and Asian language support.

What it does

  • 4-tier locale selection: URL parameter → Session → Accept-Language header → Default
  • Cyrillic-aware formatting: Russian number formatting (1 234,56 instead of 1,234.56)
  • Proper pluralization: Handles complex rules (Russian: 1/2-4/5+ forms)
  • Context-aware translations: Disambiguate homonyms
  • Time-ago utilities: "2 hours ago" with correct plurals

Built while working on wallmarkets. Tested with English, Russian, Mongolian, Chinese.

Installation

pip install flask-i18n-pro

Usage

Basic setup

from flask import Flask
from flask_i18n_pro import setup_i18n

app = Flask(__name__)
app.config['LANGUAGES'] = ['en', 'ru', 'mn', 'zh']

setup_i18n(app)
# Locale now auto-selected per request

Formatting in templates

{# Date/time #}
{{ order.created_at|format_order_datetime }}
{# en: "Dec 25, 2023, 2:30 PM" #}
{# ru: "25 дек. 2023 г., 14:30" #}

{# Price - Cyrillic formatting #}
{{ product.price|format_price('RUB') }}
{# en: "RUB 15,000.00" #}
{# ru: "15 000,00 ₽" (space separator!) #}

{# Time ago #}
{{ comment.created_at|time_ago }}
{# en: "2 minutes ago" #}
{# ru: "2 минуты назад" #}

Cyrillic number formatting

This is the main difference from Flask-Babel:

from flask_i18n_pro import format_weight

# With Russian locale
format_weight(1234.5)  # → "1 234,5"
# Not "1,234.5" like Flask-Babel does

Locale selection

Automatic 4-tier fallback:

  1. ?lang=ru URL parameter → saves to session
  2. session['lang'] if previously set
  3. Accept-Language header from browser
  4. Default configured language

Configuration

app.config['LANGUAGES'] = ['en', 'ru', 'mn', 'zh']
app.config['BABEL_DEFAULT_LOCALE'] = 'en'
app.config['BABEL_TRANSLATION_DIRECTORIES'] = 'translations'

License

MIT

Contributing

Pull requests welcome. Please add tests.

Metadata

Release files for flask-i18n-pro 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flask-i18n-pro 1.0.0
File Size Uploaded Provenance Actions
flask_i18n_pro-1.0.0.tar.gz 11.0 kB Without provenance Details for flask_i18n_pro-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flask-i18n-pro 1.0.0
File Interpreter ABI Platform Actions
flask_i18n_pro-1.0.0-py3-none-any.whl Python 3 none any Details for flask_i18n_pro-1.0.0-py3-none-any.whl

Total release size: 22.4 kB

Release files / flask_i18n_pro-1.0.0.tar.gz

Download URL flask_i18n_pro-1.0.0.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b1cb2d5f240b0c28083c676799bbc3cb6316440a0d07591b85880c8c2d18d34a
BLAKE2b-256 checksum
How to use checksums
a5e03868ed81b1f540d75d60e9b5ea5cf6c772ee452549edd7663337bededc00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / flask_i18n_pro-1.0.0-py3-none-any.whl

Download URL flask_i18n_pro-1.0.0-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
26114b7a5c18f3b84630e7eaccc5e104c56f8fdc7275a0d466890845f666ce5e
BLAKE2b-256 checksum
How to use checksums
e37653694bf578def0264440aa4456bf300dc8cf70db38adcbbb3bd033bf5987
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for flask-i18n-pro 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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