That's a great idea! I'll see if I can squeeze out a patch for this,
since I feel that I want to be able to indent blocktrans without
having the extra spaces in the po files (I realize one can remove the
extra spaces manually in the po files, but I like consistent
autogeneration hehe).

In other words, whitespace equal to the amount of the indentation of
first line will be removed, as well as leading and trailing whitespace
and line breaks.
One question that springs to mind: If the first line is on the same
line as the {% blocktrans %}tag itself (i.e. it has no indentation),
should we strip the subsequent lines based on the indentation of the
second line, or assume that the user wants to keep the text as is?

:)
Please advise.

On Oct 27, 12:41 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2007-10-26 at 15:04 +0000, Dmitri Fedortchenko wrote:
> > I've started using blocktrans in my templates and noticed that when
> > using make_messages it includes all the tabs and linebreaks around the
> > text that is surrounded by blocktrans tags.
>
> > For example:
> >           {% blocktrans %}
> >                  Translate this string
> >                  {% plural %}
> >                  And this plural string
> >           {% endblocktrans %}
>
> > Will turn into:
> > "\t\t\t\tTranslate this string"
> > "\t\t"
> > Plural:
> > "\t\t"
> > "\t\t\t\tAnd this plural string"
>
> > in the .po file... (it affects both normal blocktrans and plural
> > blocktrans)
>
> > This is rather ugly i think. Also in HTML, indentation and linebreaks
> > are generally ignored, so in that sense django does not behave
> > correctly. If you have a string of some length you might not want to
> > place it all on the same line, for the beauty of the syntax...
>
> > So I put in some preliminary work for stripping the translation
> > string.
> > I just realised that my patch only strips the ends of the string which
> > still leaves the middle full of ugliness if you have a multiline
> > msgid.
>
> > Has this ever been discussed?
> > To what extent would the stripping be appropriate? Or perhaps there is
> > a simpler solution that I am missing?
>
> There are really two things at work here: one not so good and one that I
> don't want to change.
>
> The first issue (which is worth fixing) is the leading whitespace and
> particularly the bonus blank lines that appear to be introduced. They
> are worth stripping.
>
> The second issue is what to when we fix blocktrans so that it can
> correctly handle *blocks* of text (things with newlines). In that case,
> I wouldn't want to strip anything beyond a common amount of leading
> whitespace because the source layout can be indicative of meaning
> sometimes (or at least, useful). PO files don't need to preserve
> linebreaks, so the translator can do whatever they want there, but
> arbitrarily stripping and merging feels slightly wrong to me.
>
> Whitespace may well be ignore by HTML processors(not entirely true in
> all cases, but a reasonable generalisation), but it's not ignored by
> humans reading the text. Strip out all whitespace between tags in an
> HTML page and notice how completely unreadable it becomes.
>
> So I'd be happy to include something that stripped the same amount of
> whitespace from the front of every line inside a blocktrans block but
> kept other linebreaks and extra leading whitespace intact. That would
> make the PO file more readable. Anything more compressing than that is
> going to require stronger arguments.
>
> Regards,
> Malcolm
>
> --
> Monday is an awful way to spend 1/7th of your 
> life.http://www.pointy-stick.com/blog/


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

Reply via email to