My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Usage  
Usage instructions for django-localdates
Updated Feb 4, 2010 by orestis

Usage

1. svn co http://django-localdates.googlecode.com/svn/trunk/localdates /somewhere/in/the/PYTHONPATH/localdates

2. Add 'localdates' in your settings' INSTALLED_APPS

3. In the templates that you want to use the localdates filter, add {% load local_datefilter %}.

4. You can now use the ldate filter, like that:

{{ date_object|ldate:"d {Fp} Y" }}
{{ date_object|ldate:"{FULL_DATE}" }}
{{ date_object|ldate:"d F Y" }}

You can browse the source code to find the available format strings - once they're finalized I'll write up documentation for them.

5. Checkout the test-localdates project for sample usage. (svn co http://django-localdates.googlecode.com/svn/trunk/test-localdates test-localdates)

6. Probably your locale wouldn't be available in the application. If you want to add it, do a make-messages.py -l lang, from the localdates directory, so that the django.po file will be generated. You can then add your locale's datestrings, do a compile-messages.py and reload. You may need to restart the dev server. Don't forget to attach the file in the issue tracker so I can update the source. 7. Check out the sample django/contrib/localflavor-sample package for ways of extending the current functionality. NOTE: It's best to contact me directly, as this might change.

Comment by leotrub...@gmail.com, Apr 20, 2008

Hi! I use following middleware:

class DjangoLocaleSwitchMiddleware(object):
    def process_request(self, request):
        lang = get_language()
        loc = 'en_US.UTF-8'
        if lang == 'ru':
            loc = 'ru_RU.UTF-8'
        elif lang == 'kk':
            loc = 'kk_KZ.UTF-8'
        locale.setlocale(locale.LC_ALL, loc)

Of course it's not so flexible as yours, but it's simpler


Sign in to add a comment
Powered by Google Project Hosting