Repository: freedomofpress/securedrop

Issue:
Don't use DRY string creation
# Feature request

## Description

We should not be DRY with string creation. Example sadness.

```python
if docs and not message:
    things = 'docs'
elif not docs and message:
    things = 'message'
else:
    things = 'docs and message'

msg = 'Thanks! We received your {things}.'.format(things)
```

This is bad for i18n because in some languages, you have to decline/inflect the "your" in the string to match the gender/plurality of the translated string. This will lead to grammatically incorrect sentences. Also, this DRYness is harder on translators. This is already problem in German as there is a different "your" for the two cases.

## User Stories

As a non-English speaking journalist (or source), I want to have a grammatically / syntactically accurate interface.

As a translator, I want to have to be able to have greater control over word ordering in my translations.
l10n: merge install tor strings
# Bug

## Description

The [install tor recommendation](https://github.com/freedomofpress/securedrop/blob/develop/securedrop/source_templates/index.html#L18)

<pre>
<strong>We recommend using Tor Browser to access SecureDrop:</strong> <a id="recommend-tor" href="{{ url_for('recommend_tor_browser') }}">Learn how to install it</a>, or ignore this warning to continue.
</pre>

![source-index_javascript](https://user-images.githubusercontent.com/433594/29967815-cd04e90e-8f18-11e7-8e13-d1e529e4ec0f.png)

is split into three strings which is difficult for translators to handle and contextualize. It should be a single string instead.

## Steps to Reproduce

Go to [the french translation](https://weblate.securedrop.club/translate/securedrop/securedrop/fr/?type=all&offset=163) of **, or ignore this warning to continue.** and imagine the confusion if you do not know the context.

## Expected Behavior

The translation stands by itself and the only thing necessary is the glossary.

## Actual Behavior

Confusion



Discussion:
This has been a source of confusion with the french translation, during review. I would indeed be better to duplicate the strings.


Resolving patch:
diff --git a/securedrop/journalist.py b/securedrop/journalist.py
--- a/securedrop/journalist.py
+++ b/securedrop/journalist.py
@@ -633,8 +633,8 @@ def col_delete_single(filesystem_id):
     """deleting a single collection from its /col page"""
     source = get_source(filesystem_id)
     delete_collection(filesystem_id)
-    flash(gettext("{source_journalist_designation}'s collection deleted")
-          .format(source_journalist_designation=source.journalist_designation),
+    flash(gettext("{source_name}'s collection deleted")
+          .format(source_name=source.journalist_designation),
           "notification")
     return redirect(url_for('index'))
 
@@ -738,10 +738,9 @@ def generate_code():
     db_session.commit()
 
     flash(gettext(
-        "The source '{original_source}' has been"
-        " renamed to '{new_source}'")
-          .format(original_source=original_journalist_designation,
-                  new_source=g.source.journalist_designation),
+        "The source '{original_name}' has been renamed to '{new_name}'")
+          .format(original_name=original_journalist_designation,
+                  new_name=g.source.journalist_designation),
           "notification")
     return redirect('/col/' + g.filesystem_id)
 
diff --git a/securedrop/source.py b/securedrop/source.py
--- a/securedrop/source.py
+++ b/securedrop/source.py
@@ -315,14 +315,15 @@ def submit():
 
     else:
         if msg and not fh:
-            things = 'message'
+            html_contents = gettext('Thanks! We received your message.')
         elif not msg and fh:
-            things = 'document'
+            html_contents = gettext('Thanks! We received your document.')
         else:
-            things = 'message and document'
+            html_contents = gettext('Thanks! We received your message and '
+                                    'document.')
 
         msg = render_template('next_submission_flashed_message.html',
-                              things=things)
+                              html_contents=html_contents)
         flash(Markup(msg), "success")
 
     for fname in fnames:


Test patch: