On Sun, 2009-03-22 at 23:32 -0700, John Handelaar wrote:
> On Mar 22, 11:55 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
> wrote:
> > On Sun, 2009-03-22 at 21:38 +0000, JohnHandelaarwrote:
> > > Hello
> >
> > > So if my translation string in a template currently looks like this:
> >
> > >   A book called "Gulliver's Travels"
> >
> > > ...how do I convert that into something starting with "{% trans"   ?
> >
> > You would mark the whole string for translation and, in the course of
> > translating it, the translators would replace "..." with «...» or „...“
> > or whatever. It's generally ill-advised (and very fragile) to mark only
> > a portion of a sentence for translation,
> 
> [snip]
> 
> > If that doesn't answer your question, could you explain a bit more what
> > the problem is?
> 
> Specifically I'm looking at something I've inherited which writes out
> a tiny snippet of JS which calls i18n/setlang and (ironically) appears
> to be resistant to being localised itself. If I were able to use both
> single and double quotes in a string I could put those 20 characters
> in a translated string and have done with it.  But i18n doesn't
> support escaping, it seems.

Ah, ok. That particular problem -- being able to use double- or
single-quotes to mark content for template tags and correctly handling
escaped quote marks -- is something I'm working on right this minute,
coincidentally. I actually have django/templates/__init__.py (and a few
other files) open, beating that into shape.

A workaround for now is to use Javascript character escaping to encode
the quote marks: "\u1234", etc.

You've hit a bit of an edge-case here, so that's the best I can offer
for now.

> 
> A better way of writing out a different link in a template based on
> whether it's in one language or the other (this app uses only two)
> would of course also be welcome.

Yeah, that's a tough problem, in a way. Getting an API that is usable
and useful is a little fiddly. You should feel very free to come up with
ideas if you want a fun problem to think about.

To solve your particular problem here, though, it might be possible to
write your own version of the url template tag. Writing custom template
tags is easy enough (and documented). Writing a templtae tag that more
or less wraps another template tag is probably even more
straightforward.

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to