Repository: freedomofpress/securedrop

Issue:
Error 500 on app startup when language `en` is in `securedrop_supported_locales`
# Bug

## Description
Using `en` in `securedrop_supported_locales` results in app unable to startup.
Validation logic in both in `develop` (new sdconfig) and in `0.5.2` allow a user to specify `en`
## Steps to Reproduce

- `vagrant up /prod/ --no-provision`
- in tails, `securedrop_supported_locales` in `install_files/ansible-base/group-vars/all/site-specific`should contain `en` and `fr_FR` 
- `securedrop-admin install`

## Expected Behavior
Once the installation completes, Source and Journalist interface web interface starts and responds to web requests. 
## Actual Behavior
Installation completes successfully, but when attempting to connect to source or journalist interface results in an Internal Server Error:
from `/var/log/apache2/journalist-error.log`
```
[Fri Feb 09 00:14:53.874744 2018] [:error] [pid 1437:tid 2929872570112] [remote 127.0.0.1:48940] LocaleNotFound: config.py SUPPORTED_LOCALES contains [u'en'] which is not among the locales found in the /var/www/securedrop/translations directory: ['en_US', 'nb_NO', 'pt_BR', 'es_ES', 'nl', 'zh_Hant', 'it_IT', 'tr', 'fr_FR', 'ar', 'de_DE', 'nb_NO', 'pt_BR', 'es_ES', 'nl', 'zh_Hant', 'it_IT', 'tr', 'fr_FR', 'ar', 'de_DE', 'nb_NO', 'pt_BR', 'es_ES', 'nl', 'zh_Hant', 'it_IT', 'tr', 'fr_FR', 'ar', 'de_DE', 'nb_NO', 'pt_BR', 'es_ES', 'nl', 'zh_Hant', 'it_IT', 'tr', 'fr_FR', 'ar', 'de_DE', 'nb_NO', 'pt_BR', 'es_ES', 'nl', 'zh_Hant', 'it_IT', 'tr', 'fr_FR', 'ar', 'de_DE', 'nb_NO', 'pt_BR', 'es_ES', 'nl', 'zh_Hant', 'it_IT', 'tr', 'fr_FR', 'ar', 'de_DE', 'nb_NO', 'pt_BR', 'es_ES', 'nl', 'zh_Hant', 'it_IT', 'tr', 'fr_FR', 'ar', 'de_DE', 'nb_NO', 'pt_BR', 'es_ES', 'nl', 'zh_Hant', 'it_IT', 'tr', 'fr_FR', 'ar', 'de_DE', 'nb_NO', 'pt_BR', 'es_ES', 'nl', 'zh_Hant', 'it_IT', 'tr', 'fr_FR', 'ar', 'de_DE', 'nb_NO', 'pt_BR', 'es_ES', 'nl', 'zh_Hant', 'it_IT', 'tr', 'fr_FR', 'ar', 'de_DE', 'nb_NO', 'pt_BR', 'es_ES', 'nl', 'zh_Hant', 'it_IT', 'tr', 'fr_FR', 'ar', 'de_DE', 'nb_NO', 'pt_BR', 'es_ES', 'nl', 'zh_Hant', 'it_IT', 'tr', 'fr_FR', 'ar', 'de_DE', 'nb_NO', 'pt_BR', 'es_ES', 'nl', 'zh_Hant', 'it_IT', 'tr', 'fr_FR', 'ar', 'de_DE']
[Fri Feb 09 00:14:53.874821 2018] [core:error] [pid 1441:tid 2929804687104] [client 127.0.0.1:48470] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
```



Discussion:

Resolving patch:
diff --git a/admin/securedrop_admin/__init__.py b/admin/securedrop_admin/__init__.py
--- a/admin/securedrop_admin/__init__.py
+++ b/admin/securedrop_admin/__init__.py
@@ -154,7 +154,7 @@ def __init__(self, appdir):
                 os.path.join(appdir, 'translations'))
 
         def get_translations(self):
-            translations = set(['en', 'en_US'])
+            translations = set(['en_US'])
             for dirname in os.listdir(self.translation_dir):
                 if dirname != 'messages.pot':
                     translations.add(dirname)


Test patch:
diff --git a/admin/tests/test_securedrop-admin.py b/admin/tests/test_securedrop-admin.py
--- a/admin/tests/test_securedrop-admin.py
+++ b/admin/tests/test_securedrop-admin.py
@@ -383,9 +383,9 @@ def verify_prompt_securedrop_supported_locales(self, site_config, desc):
         assert site_config.user_prompt_config_one(desc, None) == default
         assert type(default) == etype
         assert site_config.user_prompt_config_one(
-            desc, 'en en_US') == ['en', 'en_US']
+            desc, 'fr_FR en_US') == ['fr_FR', 'en_US']
         assert site_config.user_prompt_config_one(
-            desc, ['en', 'en_US']) == ['en', 'en_US']
+            desc, ['fr_FR', 'en_US']) == ['fr_FR', 'en_US']
         assert site_config.user_prompt_config_one(desc, '') == []
         with pytest.raises(ValidationError):
             site_config.user_prompt_config_one(desc, 'wrong')