-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Notifications: remove extra indentation and trailing newlines #10987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You can use import textwrap
s = textwrap.dedent(
"""
Foo
bar
"""
).strip() |
That works great! However, it seems that
|
+1 on dedent here It looks like you are effectively doing To both make the source easy to work with and also solve the issue of the translations including extraneous whitespace, you probably need |
Noted at #10922 (comment)
I'll add this to this sprint, as I'd like to help translators as much we can here. I don't really know if it matters though. Moving the string is probably already a somewhat breaking change. |
Yes, I tried doing the first approach because doing |
Yeah, I figured we'd have to do something like this, unfortunately. Multiline strings are always a pain. I do believe there is magic you can do with gettext and creating your own gettext wrappers, but this is almost certainly way too deep. |
I don't know exactly how gettext works internally, but I assumed that if I do
|
I understand that we can't translate variables in a simple way:
(from https://docs.djangoproject.com/en/5.0/topics/i18n/translation/#standard-translation) I think what I've done here is the way to go, unfortunately 😞 |
I've found myself wanting to write the copy for all the messages in a simple way that avoid indentation and punctuation mistakes and I'm happy with the result so far. However, the downsides they have is they return they messages as
\n \n Please try...
(note the\n
and the extra spaces).I'd like to remove those automatically somehow without changing the way we write down the copy for these messages if possible.
We discussed this a little at #10922 (comment) where I exposed what I ideally want.
Example in the code:
readthedocs.org/readthedocs/notifications/messages.py
Lines 71 to 78 in 7d1daee
The text was updated successfully, but these errors were encountered: