django-icanhaz icon indicating copy to clipboard operation
django-icanhaz copied to clipboard

i18n not possible with this solution?

Open mbrochh opened this issue 13 years ago • 3 comments

do I understand this correctly? With this solution it would not be possible to have {% trans "foo" %} tags in the icanhaz templates since those are no longer being parsed by django?

how do you handle i18n in your projects when using django-icanhaz?

mbrochh avatar Aug 15 '11 11:08 mbrochh

True - I haven't yet needed both i18n and JS templating in the same project. It would not be too hard to add a pre-processing step specifically for i18n; doesn't seem worth running it through the Django template engine just for that.

carljm avatar Aug 19 '11 00:08 carljm

what about another tags {% url %}, {% now "jS F Y H:i" %}, and many others.... @mbrochh I recommend you this custom template tag (https://gist.github.com/893408), improved by @maraujo from @ericflo's initial version.

So, @carljm, I recommend you parse templates with django engine and I thank you for this app.

rmaceissoft avatar Dec 20 '11 16:12 rmaceissoft

@rmaceissoft Rather than using {% url %} directly in an icanhaz template, you can use it in a Django template and put the url in a data- attribute that JS can access and use when rendering the icanhaz template. As for now, Javascript itself can render the current time without help from Django; if you need the server version of the current time, you can take a similar approach with a data attribute. This may seem like more work, but in our experience it's compensated by the gain of having a clear mental separation between the server side and the client side and more readable templates.

Translation is more of a puzzle; I think it would make sense to add dedicated "translation" syntax to django-icanhaz and run a translation step on the template before outputting it. I'll probably get around to adding that when I run into the need for it.

Thanks for your comment!

carljm avatar Dec 20 '11 18:12 carljm