Changes between Initial Version and Version 1 of Ticket #24257, comment 4


Ignore:
Timestamp:
Apr 24, 2015, 12:58:49 AM (9 years ago)
Author:
Doug Beck

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #24257, comment 4

    initial v1  
    99 == Long story long  ==
    1010
    11 In an ideal world we would be able to use the template string (with it's curly brace variables) as our msgid.  Since that is not possible, template copy is coerced into a python formatted / sprintf string.
     11In an ideal world we would be able to use the template string (with it's curly brace variables) as our msgid.  Since that is not possible, template copy is coerced into a python string format / sprintf string.
    1212
    1313This is a source of much pain and confusion, especially with percent signs.  Why?
     
    2525}}}
    2626
    27 This is all good.  It gets awkward when you pass it an invalid python fmt string, say:
     27This is all good.  It gets awkward when you pass it an invalid str fmt, say:
    2828
    2929{{{
     
    3636This is awkward because the single `%` is seen as invalid python format and so the message id is not marked as we would expect.
    3737
    38 '''sprintf is awkward.'''
     38This is a potential source of bugs.  If the translation comes back as `%s precio 10%`, compiling messages won't catch the issue since it is not marked python-format and django will blow up because string interpolation requires `%s precio 10%%`.
     39
     40'''str fmt / sprintf is awkward.'''
    3941
    4042Since humans are bad parsers, when I look at the format, `% %s` I see a percent followed by a string specifier. What this actually means a percent sign specifier, with a whitespace conversion flag, followed by an `s` character.
Back to Top