[Python-il] Newbie question: localizing dates without setlocale
meir at mksoft.co.il
Tue Feb 19 12:45:53 IST 2008
Udi h Bauman wrote:
> I have a small question which I hope one of you experts will be kind
> enough to help with.
> I wrote a web page which I need to translate to different languages
> (http://staging.daylight-savings-time.info). I need to translate the day
> & month names, which I generate using /strftime/. I need it to output
> the date parts for a given locale. I've tried using setlocale, but it
> apparently affected the full python process at the web server (it's a
> Django app) & all user sessions. Is there a way to generate dates for a
> given locale without setlocale?
> Thanks a lot in advance!
One of the lookups django does to determine the current language is
looking in the session for the key "django_language"  (this allows a
specific language for each user).
I see that you're using the set_language view (which updates the
django_language var), so wheres the problem ? I've already translated
the date and month names in Django, can't you reuse them (e.g. in the
templates using the specific date filter) ?
Note that the above behavior (setting and submitting the form in js)
prevents search engines from indexing the other language pages.
BTW, lazy loading of translations might be problematic, if that's the
case (and only if thats the case), try to minimize the usage of them
More information about the Python-il