Glashammer provides internationalization out of the box using the Babel library. You can enable it by adding the i18n bundle during application setup:
from glashammer.bundles.i18n import setup_i18n
app.add_setup(setup_i18n)
The language is decided by the configuration variable ‘language’.
The i18n bundle provides two template filters which format dates, or datetimes into the locale’s current format. These filters accept an additional argument which is the format type (‘short’, ‘medium’, ‘long’; default is ‘medium’) and so can be used in a template like so for a date object:
{{ d|formatdate('long') }}
The API of the actual functions, if you want or need to use them outside templates, are as so:
format a datetime object to the current language
format a date object to the current language
i18n tools for Glashammer.
| copyright: | Copyright 2008 by Armin Ronacher. |
|---|---|
| license: | MIT |