Merge pull request #6851 from edx/ned/fix-gettext-literals
Fix a number of incorrect translation string uses.
This commit is contained in:
@@ -32,7 +32,7 @@ class GitExportError(Exception):
|
||||
|
||||
NO_EXPORT_DIR = _("GIT_REPO_EXPORT_DIR not set or path {0} doesn't exist, "
|
||||
"please create it, or configure a different path with "
|
||||
"GIT_REPO_EXPORT_DIR".format(GIT_REPO_EXPORT_DIR))
|
||||
"GIT_REPO_EXPORT_DIR").format(GIT_REPO_EXPORT_DIR)
|
||||
URL_BAD = _('Non writable git url provided. Expecting something like:'
|
||||
' git@github.com:mitocw/edx4edx_lite.git')
|
||||
URL_NO_AUTH = _('If using http urls, you must provide the username '
|
||||
|
||||
@@ -62,7 +62,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
course_key = SlashSeparatedCourseKey.from_deprecated_string(args[0])
|
||||
except InvalidKeyError:
|
||||
raise CommandError(_(GitExportError.BAD_COURSE))
|
||||
raise CommandError(unicode(GitExportError.BAD_COURSE))
|
||||
|
||||
try:
|
||||
git_export_utils.export_to_git(
|
||||
@@ -72,4 +72,4 @@ class Command(BaseCommand):
|
||||
options.get('rdir', None)
|
||||
)
|
||||
except git_export_utils.GitExportError as ex:
|
||||
raise CommandError(_(ex.message))
|
||||
raise CommandError(unicode(ex.message))
|
||||
|
||||
@@ -137,7 +137,7 @@ def _create_library(request):
|
||||
except KeyError as error:
|
||||
log.exception("Unable to create library - missing required JSON key.")
|
||||
return JsonResponseBadRequest({
|
||||
"ErrMsg": _("Unable to create library - missing required field '{field}'".format(field=error.message))
|
||||
"ErrMsg": _("Unable to create library - missing required field '{field}'").format(field=error.message)
|
||||
})
|
||||
except InvalidKeyError as error:
|
||||
log.exception("Unable to create library - invalid key.")
|
||||
|
||||
@@ -117,8 +117,8 @@ class CourseMetadata(object):
|
||||
if hasattr(descriptor, key) and getattr(descriptor, key) != val:
|
||||
key_values[key] = descriptor.fields[key].from_json(val)
|
||||
except (TypeError, ValueError) as err:
|
||||
raise ValueError(_("Incorrect format for field '{name}'. {detailed_message}".format(
|
||||
name=model['display_name'], detailed_message=err.message)))
|
||||
raise ValueError(_("Incorrect format for field '{name}'. {detailed_message}").format(
|
||||
name=model['display_name'], detailed_message=err.message))
|
||||
|
||||
return cls.update_from_dict(key_values, descriptor, user)
|
||||
|
||||
|
||||
@@ -80,10 +80,9 @@ log = logging.getLogger(__name__)
|
||||
# Make '_' a no-op so we can scrape strings
|
||||
_ = lambda text: text
|
||||
|
||||
DOCS_ANCHOR_TAG = (
|
||||
"<a target='_blank'"
|
||||
DOCS_ANCHOR_TAG_OPEN = (
|
||||
"<a target='_blank' "
|
||||
"href='http://edx.readthedocs.org/projects/ca/en/latest/exercises_tools/lti_component.html'>"
|
||||
"the edX LTI documentation</a>"
|
||||
)
|
||||
|
||||
|
||||
@@ -122,7 +121,10 @@ class LTIFields(object):
|
||||
"Enter the LTI ID for the external LTI provider. "
|
||||
"This value must be the same LTI ID that you entered in the "
|
||||
"LTI Passports setting on the Advanced Settings page."
|
||||
"<br />See " + DOCS_ANCHOR_TAG + " for more details on this setting."
|
||||
"<br />See {docs_anchor_open}the edX LTI documentation{anchor_close} for more details on this setting."
|
||||
).format(
|
||||
docs_anchor_open=DOCS_ANCHOR_TAG_OPEN,
|
||||
anchor_close="</a>"
|
||||
),
|
||||
default='',
|
||||
scope=Scope.settings
|
||||
@@ -132,7 +134,10 @@ class LTIFields(object):
|
||||
help=_(
|
||||
"Enter the URL of the external tool that this component launches. "
|
||||
"This setting is only used when Hide External Tool is set to False."
|
||||
"<br />See " + DOCS_ANCHOR_TAG + " for more details on this setting."
|
||||
"<br />See {docs_anchor_open}the edX LTI documentation{anchor_close} for more details on this setting."
|
||||
).format(
|
||||
docs_anchor_open=DOCS_ANCHOR_TAG_OPEN,
|
||||
anchor_close="</a>"
|
||||
),
|
||||
default='http://www.example.com',
|
||||
scope=Scope.settings)
|
||||
@@ -141,7 +146,10 @@ class LTIFields(object):
|
||||
help=_(
|
||||
"Add the key/value pair for any custom parameters, such as the page your e-book should open to or "
|
||||
"the background color for this component."
|
||||
"<br />See " + DOCS_ANCHOR_TAG + " for more details on this setting."
|
||||
"<br />See {docs_anchor_open}the edX LTI documentation{anchor_close} for more details on this setting."
|
||||
).format(
|
||||
docs_anchor_open=DOCS_ANCHOR_TAG_OPEN,
|
||||
anchor_close="</a>"
|
||||
),
|
||||
scope=Scope.settings)
|
||||
open_in_a_new_page = Boolean(
|
||||
|
||||
@@ -49,7 +49,7 @@ class SequenceFields(object):
|
||||
is_entrance_exam = Boolean(
|
||||
display_name=_("Is Entrance Exam"),
|
||||
help=_(
|
||||
"Tag this course module as an Entrance Exam. " +
|
||||
"Tag this course module as an Entrance Exam. "
|
||||
"Note, you must enable Entrance Exams for this course setting to take effect."
|
||||
),
|
||||
scope=Scope.content,
|
||||
|
||||
@@ -463,7 +463,7 @@ class Courses(SysadminDashboardView):
|
||||
# new, and pull is when it is being updated from the
|
||||
# source.
|
||||
return _('Unable to clone or pull repository. Please check '
|
||||
'your url. Output was: {0!r}'.format(ex.output))
|
||||
'your url. Output was: {0!r}').format(ex.output)
|
||||
|
||||
msg += u'<pre>{0}</pre>'.format(cmd_output)
|
||||
if not os.path.exists(gdir):
|
||||
@@ -479,7 +479,7 @@ class Courses(SysadminDashboardView):
|
||||
# specific version of a courses content
|
||||
msg += u'<p>{0}</p>'.format(
|
||||
_('Successfully switched to branch: '
|
||||
'{branch_name}'.format(branch_name=branch)))
|
||||
'{branch_name}').format(branch_name=branch))
|
||||
|
||||
self.def_ms.try_load_course(os.path.abspath(gdir))
|
||||
errlog = self.def_ms.errored_courses.get(cdir, '')
|
||||
|
||||
@@ -374,7 +374,7 @@ def register_and_enroll_students(request, course_id): # pylint: disable=too-man
|
||||
except Exception as ex:
|
||||
log.exception(type(ex).__name__)
|
||||
row_errors.append({
|
||||
'username': username, 'email': email, 'response': _(type(ex).__name__)})
|
||||
'username': username, 'email': email, 'response': type(ex).__name__})
|
||||
else:
|
||||
# It's a new user, an email will be sent to each newly created user.
|
||||
email_params['message'] = 'account_creation_and_enrollment'
|
||||
@@ -887,7 +887,7 @@ def sale_validation(request, course_id):
|
||||
try:
|
||||
obj_invoice = Invoice.objects.select_related('is_valid').get(id=invoice_number, course_id=course_id)
|
||||
except Invoice.DoesNotExist:
|
||||
return HttpResponseNotFound(_("Invoice number '{0}' does not exist.".format(invoice_number)))
|
||||
return HttpResponseNotFound(_("Invoice number '{0}' does not exist.").format(invoice_number))
|
||||
|
||||
if event_type == "invalidate":
|
||||
return invalidate_invoice(obj_invoice)
|
||||
|
||||
@@ -1381,7 +1381,10 @@ class CertificateItem(OrderItem):
|
||||
else:
|
||||
msg = u"Mode {mode} does not exist for {course_id}".format(mode=mode, course_id=course_id)
|
||||
log.error(msg)
|
||||
raise InvalidCartItem(_(msg))
|
||||
raise InvalidCartItem(
|
||||
_(u"Mode {mode} does not exist for {course_id}").format(mode=mode, course_id=course_id)
|
||||
)
|
||||
|
||||
item, _created = cls.objects.get_or_create(
|
||||
order=order,
|
||||
user=order.user,
|
||||
@@ -1649,7 +1652,9 @@ class Donation(OrderItem):
|
||||
if course is None:
|
||||
msg = u"Could not find a course with the ID '{course_id}'".format(course_id=course_id)
|
||||
log.error(msg)
|
||||
raise CourseDoesNotExistException(_(msg))
|
||||
raise CourseDoesNotExistException(
|
||||
_(u"Could not find a course with the ID '{course_id}'").format(course_id=course_id)
|
||||
)
|
||||
|
||||
return _(u"Donation for {course}").format(course=course.display_name)
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ class PDFInvoice(object):
|
||||
y_pos = y_pos - font_size / 2 - vertical_padding
|
||||
# Draw Order/Invoice No.
|
||||
self.pdf.drawString(horizontal_padding_from_border, y_pos,
|
||||
_(u'{id_label} # {item_id}'.format(id_label=id_label, item_id=self.item_id)))
|
||||
_(u'{id_label} # {item_id}').format(id_label=id_label, item_id=self.item_id))
|
||||
y_pos = y_pos - font_size / 2 - vertical_padding
|
||||
# Draw Date
|
||||
self.pdf.drawString(
|
||||
|
||||
@@ -166,13 +166,13 @@ def payment_accepted(params):
|
||||
('decision', str)]:
|
||||
if key not in params:
|
||||
raise CCProcessorDataException(
|
||||
_("The payment processor did not return a required parameter: {0}".format(key))
|
||||
_("The payment processor did not return a required parameter: {0}").format(key)
|
||||
)
|
||||
try:
|
||||
valid_params[key] = key_type(params[key])
|
||||
except ValueError:
|
||||
raise CCProcessorDataException(
|
||||
_("The payment processor returned a badly-typed value {0} for param {1}.".format(params[key], key))
|
||||
_("The payment processor returned a badly-typed value {0} for param {1}.").format(params[key], key)
|
||||
)
|
||||
|
||||
try:
|
||||
@@ -187,8 +187,9 @@ def payment_accepted(params):
|
||||
charged_amt = Decimal(params['ccAuthReply_amount'])
|
||||
except InvalidOperation:
|
||||
raise CCProcessorDataException(
|
||||
_("The payment processor returned a badly-typed value {0} for param {1}.".format(
|
||||
params['ccAuthReply_amount'], 'ccAuthReply_amount'))
|
||||
_("The payment processor returned a badly-typed value {0} for param {1}.").format(
|
||||
params['ccAuthReply_amount'], 'ccAuthReply_amount'
|
||||
)
|
||||
)
|
||||
|
||||
if charged_amt == order.total_cost and valid_params['orderCurrency'] == order.currency:
|
||||
@@ -198,9 +199,13 @@ def payment_accepted(params):
|
||||
'order': order}
|
||||
else:
|
||||
raise CCProcessorWrongAmountException(
|
||||
_("The amount charged by the processor {0} {1} is different than the total cost of the order {2} {3}."
|
||||
.format(charged_amt, valid_params['orderCurrency'],
|
||||
order.total_cost, order.currency))
|
||||
_("The amount charged by the processor {0} {1} is different than the total cost of the order {2} {3}.")
|
||||
.format(
|
||||
charged_amt,
|
||||
valid_params['orderCurrency'],
|
||||
order.total_cost,
|
||||
order.currency
|
||||
)
|
||||
)
|
||||
else:
|
||||
return {'accepted': False,
|
||||
@@ -400,10 +405,9 @@ REASONCODE_MAP.update(
|
||||
Possible fix: retry with another form of payment
|
||||
""")),
|
||||
'233': _('General decline by the processor. Possible fix: retry with another form of payment'),
|
||||
'234': dedent(_(
|
||||
"""
|
||||
There is a problem with our CyberSource merchant configuration. Please let us know at {0}
|
||||
""".format(settings.PAYMENT_SUPPORT_EMAIL))),
|
||||
'234': _(
|
||||
"There is a problem with our CyberSource merchant configuration. Please let us know at {0}"
|
||||
).format(settings.PAYMENT_SUPPORT_EMAIL),
|
||||
# reason code 235 only applies if we are processing a capture through the API. so we should never see it
|
||||
'235': _('The requested amount exceeds the originally authorized amount.'),
|
||||
'236': _('Processor Failure. Possible fix: retry the payment'),
|
||||
|
||||
@@ -634,10 +634,9 @@ REASONCODE_MAP.update(
|
||||
Possible fix: retry with another form of payment
|
||||
""")),
|
||||
'233': _('General decline by the processor. Possible fix: retry with another form of payment'),
|
||||
'234': dedent(_(
|
||||
"""
|
||||
There is a problem with the information in your CyberSource account. Please let us know at {0}
|
||||
""".format(settings.PAYMENT_SUPPORT_EMAIL))),
|
||||
'234': _(
|
||||
"There is a problem with the information in your CyberSource account. Please let us know at {0}"
|
||||
).format(settings.PAYMENT_SUPPORT_EMAIL),
|
||||
'236': _('Processor Failure. Possible fix: retry the payment'),
|
||||
'240': dedent(_(
|
||||
"""
|
||||
|
||||
@@ -91,10 +91,10 @@ def add_course_to_cart(request, course_id):
|
||||
except CourseDoesNotExistException:
|
||||
return HttpResponseNotFound(_('The course you requested does not exist.'))
|
||||
except ItemAlreadyInCartException:
|
||||
return HttpResponseBadRequest(_('The course {course_id} is already in your cart.'.format(course_id=course_id)))
|
||||
return HttpResponseBadRequest(_('The course {course_id} is already in your cart.').format(course_id=course_id))
|
||||
except AlreadyEnrolledInCourseException:
|
||||
return HttpResponseBadRequest(
|
||||
_('You are already registered in course {course_id}.'.format(course_id=course_id)))
|
||||
_('You are already registered in course {course_id}.').format(course_id=course_id))
|
||||
else:
|
||||
# in case a coupon redemption code has been applied, new items should also get a discount if applicable.
|
||||
order = paid_course_item.order
|
||||
@@ -283,7 +283,7 @@ def use_code(request):
|
||||
try:
|
||||
course_reg = CourseRegistrationCode.objects.get(code=code)
|
||||
except CourseRegistrationCode.DoesNotExist:
|
||||
return HttpResponseNotFound(_("Discount does not exist against code '{code}'.".format(code=code)))
|
||||
return HttpResponseNotFound(_("Discount does not exist against code '{code}'.").format(code=code))
|
||||
|
||||
return use_registration_code(course_reg, request.user)
|
||||
|
||||
@@ -432,18 +432,22 @@ def use_registration_code(course_reg, user):
|
||||
"""
|
||||
if RegistrationCodeRedemption.is_registration_code_redeemed(course_reg):
|
||||
log.warning("Registration code '{registration_code}' already used".format(registration_code=course_reg.code))
|
||||
return HttpResponseBadRequest(_(
|
||||
"Oops! The code '{registration_code}' you entered is either invalid or expired".format(
|
||||
registration_code=course_reg.code)))
|
||||
return HttpResponseBadRequest(
|
||||
_("Oops! The code '{registration_code}' you entered is either invalid or expired").format(
|
||||
registration_code=course_reg.code
|
||||
)
|
||||
)
|
||||
try:
|
||||
cart = Order.get_cart_for_user(user)
|
||||
cart_items = cart.find_item_by_course_id(course_reg.course_id)
|
||||
except ItemNotFoundInCartException:
|
||||
log.warning("Course item does not exist against registration code '{registration_code}'".format(
|
||||
registration_code=course_reg.code))
|
||||
return HttpResponseNotFound(_(
|
||||
"Code '{registration_code}' is not valid for any course in the shopping cart.".format(
|
||||
registration_code=course_reg.code)))
|
||||
return HttpResponseNotFound(
|
||||
_("Code '{registration_code}' is not valid for any course in the shopping cart.").format(
|
||||
registration_code=course_reg.code
|
||||
)
|
||||
)
|
||||
else:
|
||||
applicable_cart_items = [
|
||||
cart_item for cart_item in cart_items
|
||||
@@ -478,7 +482,7 @@ def use_coupon_code(coupons, user):
|
||||
|
||||
if not is_redemption_applied:
|
||||
log.warning("Discount does not exist against code '{code}'.".format(code=coupons[0].code))
|
||||
return HttpResponseNotFound(_("Discount does not exist against code '{code}'.".format(code=coupons[0].code)))
|
||||
return HttpResponseNotFound(_("Discount does not exist against code '{code}'.").format(code=coupons[0].code))
|
||||
|
||||
return HttpResponse(
|
||||
json.dumps({'response': 'success', 'coupon_code_applied': True}),
|
||||
|
||||
Reference in New Issue
Block a user