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