Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.
/ flask-icu Public archive
forked from python-babel/flask-babel

i18n and l10n support for Flask based on ICU and pytz

License

Notifications You must be signed in to change notification settings

beavyHQ/flask-icu

 
 

Repository files navigation

Flask ICU

Build Status

Implements i18n and l10n support for Flask using the industry standard ICU.

Understanding ICU Syntax

Simple example:

I have {numCats, plural
  =0 {no cats}
  one {one cat}
  other {{numCats} cats}}.

Consult these links in order to better understand ICU syntax:

API

format()

format('You have {num} messages.', {'num': 3})
# => You have 3 messages.

format_date()

format_date(datetime(2010, 4, 12, 13, 46))
# => Apr 12, 2010

format_time()

format_time(datetime(2010, 4, 12, 13, 46))
# => 1:46:00 PM

format_datetime()

format_datetime(datetime(2010, 4, 12, 13, 46))
# => Apr 12, 2010, 3:46:00 PM

format_number()

format_number(1099)
# => 1,099

format_decimal()

format_decimal(Decimal('1010.99'))
# => 1,010.99

format_currency()

format_currency(1099, 'ILS')
# => ₪1,099.00

format_scientific()

format_scientific(10000)
# => 1E4

format_percent()

format_percent(0.19)
# => 19%

Contribution Notes

Contributions are welcome. Please contact me if you are interested in making a contribution.

The tests include a limited number of translation messages. The process for extracting these messages requires the use of pybabel and po2json. Here are the steps:

  1. Use pybabel to extract messages from tests file
  2. Initialize translation files
  3. Use po2json to generate json translation files

About

i18n and l10n support for Flask based on ICU and pytz

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 96.7%
  • Shell 2.1%
  • Makefile 1.2%