openpolis / open_municipio

Transparency in italian Comuni
GNU Affero General Public License v3.0
54 stars 16 forks source link

Datetime string not localized in Solr/Haystack #536

Closed scaloni closed 9 years ago

scaloni commented 10 years ago

Indexing by month is enabled by prepare_month method in acts/search_indexes.py

def prepare_month(self, obj):
    return obj.presentation_date.strftime("%B")

The returned string is localized in Ubuntu 14.04 development desktop but it is not localized in production server (Ubuntu 12.04 server), even if locale it_IT.utf8 is installed

(venv)om@vps36880:~$ locale -a
C
C.UTF-8
en_US.utf8
it_CH.utf8
it_IT
it_IT.iso88591
it_IT.utf8
POSIX

And localization seems to work in django-admin.py shell_plus

>>> import locale
>>> locale.getlocale()
(None, None)
>>> locale.setlocale(locale.LC_ALL, 'it_IT.utf8')
'it_IT.utf8'
>>> locale.getlocale()
('it_IT', 'UTF-8')
>>> datetime.datetime.now()
datetime.datetime(2014, 9, 10, 17, 11, 16, 446825)
>>> datetime.datetime.now().strftime("%B")
'settembre'
>>> locale.setlocale(locale.LC_ALL, '')
'en_US.utf8'
>>> datetime.datetime.now().strftime("%B")
'September'
>>> 
scaloni commented 9 years ago

Chiuso da @fspegni