[Python-il] Newbie question: localizing dates without setlocale
Meir Kriheli
meir at mksoft.co.il
Tue Feb 19 15:22:05 IST 2008
Udi h Bauman wrote:
> Great, I didn't know Django translates them. I just wrapped my call to
> strftime with a call to gettext.
>
> I'm aware of the search engine issue, & indeed needs to fix it. Is there
> a standard way to make the translation URL-based, or should I define
> URL's per language?
>
I'm not sure yet, as I'm having the same issue in Lahak (at least when
I'll have time to work on it :( ).
I wouldn't like to implement it as a language specific URL's - leads to
large URLConf, and not generic (each new language will need to modify
the URLConf).
Guess i'll probably implement it as a middleware of some sort.
Cheers
--
Meir Kriheli
http://mksoft.co.il
> Thanks a lot!
> Udi
>
> On Feb 19, 2008 12:45 PM, Meir Kriheli <meir at mksoft.co.il
> <mailto:meir at mksoft.co.il>> wrote:
>
> Udi h Bauman wrote:
> > Hi,
> >
> > 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!
> > Udi
>
> One of the lookups django does to determine the current language is
> looking in the session for the key "django_language" [1] (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
> (e.g ugetgtext_lazy).
>
>
> [1]
> http://www.djangoproject.com/documentation/i18n/#how-django-discovers-language-preference
>
> Cheers
> --
> Meir Kriheli
> http://mksoft.co.il
>
>
More information about the Python-il
mailing list