Changes between Initial Version and Version 1 of Ticket #24257, comment 4
- Timestamp:
- Apr 24, 2015, 12:58:49 AM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #24257, comment 4
initial v1 9 9 == Long story long == 10 10 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.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 string format / sprintf string. 12 12 13 13 This is a source of much pain and confusion, especially with percent signs. Why? … … 25 25 }}} 26 26 27 This is all good. It gets awkward when you pass it an invalid python fmt string, say:27 This is all good. It gets awkward when you pass it an invalid str fmt, say: 28 28 29 29 {{{ … … 36 36 This is awkward because the single `%` is seen as invalid python format and so the message id is not marked as we would expect. 37 37 38 '''sprintf is awkward.''' 38 This 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.''' 39 41 40 42 Since 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.