Re: text in translation strings?
Actually second solution will work (with django 1.10.5 at least) but with `safe` filter added (and it's more convinient to use `trimmed` than create oneliner): {% blocktrans trimmed with ''|safe as link_begin and '' as link_end %} Lorem lipsum sit dolor amet enim - {{ link_begin }}Sth{{ link_end }} {% endblocktrans %} W dniu poniedziałek, 11 stycznia 2010 10:15:25 UTC+1 użytkownik Michael P. Jung napisał: > > > I'm having a template, where a link shall be inside a translation- > > marked text. (...) > > I've recently run across a similar problem and solved it using some > nasty with-tag trickery. > > In your case the following code should do the trick: > > {% url login as login_url %} > {% with "" as link_begin %} > {% with "" as link_end %} > {% blocktrans %}Please {{ link_begin }}login{{ link_end }} to proceed. > {% endblocktrans %} > {% endwith %} > {% endwith %} > > > {% blocktrans %} also has a builtin "with" support, but for some reason > it does not support escaping special characters. > > So the following doesn't work: > > {% blocktrans with "" as link_begin > and "" as link_end %}Please {{ link_begin }}login{{ link_end }} to > proceeed.{% endblocktrans %} > > > --mp > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/68cf1856-48ef-4637-b64b-5e3af9d853c7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: text in translation strings?
> {% url login as login_url %} > {% blocktrans %}You need to login before > you can do anything {% endblocktrans %} > > I'm curious if this is good guess, so please let me know. It works! Didn't know that the url tag can name its result with "as". Thanks again :-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Re: text in translation strings?
On 10 Sty, 12:59, Andreas Pfrengle wrote: > I'm having a template, where a link shall be inside a translation- > marked text. I see two ways how to accomplish this, but both don't > work: > 1. {% trans "You need to login before > you can do anything" %} (...) > 2. {% blocktrans %}You need to login > before you can do anything {% endblocktrans %} (...) > > Is there a way with either of these tags to accomplish what I want? > I haven't tried this but maybe it will work: {% url login as login_url %} {% blocktrans %}You need to login before you can do anything {% endblocktrans %} I'm curious if this is good guess, so please let me know. -- Tomasz Zielinski http://pyconsultant.eu -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Re: text in translation strings?
> I'm having a template, where a link shall be inside a translation- > marked text. (...) I've recently run across a similar problem and solved it using some nasty with-tag trickery. In your case the following code should do the trick: {% url login as login_url %} {% with "" as link_begin %} {% with "" as link_end %} {% blocktrans %}Please {{ link_begin }}login{{ link_end }} to proceed. {% endblocktrans %} {% endwith %} {% endwith %} {% blocktrans %} also has a builtin "with" support, but for some reason it does not support escaping special characters. So the following doesn't work: {% blocktrans with "" as link_begin and "" as link_end %}Please {{ link_begin }}login{{ link_end }} to proceeed.{% endblocktrans %} --mp -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
text in translation strings?
Hello, I'm having a template, where a link shall be inside a translation- marked text. I see two ways how to accomplish this, but both don't work: 1. {% trans "You need to login before you can do anything" %} I get an template syntax error: "Searching for value. Unexpected end of string" (because of the quotes). Escaping the quotes or taking single quotes also didn't work 2. {% blocktrans %}You need to login before you can do anything {% endblocktrans %} Again template syntax error: "'blocktrans' doesn't allow other block tags (seen u'url login') inside it" Is there a way with either of these tags to accomplish what I want? Of course there would also be the possibility to mark each single part of the text, like so: 3. {% trans "You need to " %}{% trans "login before you can do anything" %} But I don't want to split the string in the middle of a sentence. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.