KeyError when generating translations

Step-by-step guide

Localizable strings often include placeholder variable names that must be included precisely in each translation. If by mistake a placeholder name is misspelled, then you will see an error something like this:

Traceback (most recent call last):
 File "/edx/app/edxapp/edx-platform/common/djangoapps/util/views.py", line 87, in inner
   return func(request, *args, **kwargs)
 File "/edx/app/edxapp/edx-platform/lms/djangoapps/certificates/views/webview.py", line 574, in render_html_view
   _update_certificate_context(context, user_certificate, platform_name)
 File "/edx/app/edxapp/edx-platform/lms/djangoapps/certificates/views/webview.py", line 111, in _update_certificate_context
   course_number=context['course_number']
KeyError: u'username'

In this example, the code was expecting to provide a variable called ``user_name`` but the translation accidentally switched it to ``username``. Unfortunately the error message does not make clear what the problem is, but the solution is to correct the translation that has the incorrect placeholder.

See the following for more details: