Implements i18n and l10n support for Flask using the industry standard ICU.
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:
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%
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:
- Use pybabel to extract messages from tests file
- Initialize translation files
- Use po2json to generate json translation files