Use JS I18n function in asset, avoid parsing error

A deployment to the French server failed because a translation contained
an apostrophe `'` and we were rendering it without escaping in
Javascript. We don't have that problem and avoid other issues by using
the javascript translate function. That way the error message is
translated in the browser with the user's language and we don't have to
do any additional escaping.
This commit is contained in:
Maikel Linke
2021-01-27 14:12:25 +11:00
parent 0393e902c4
commit 06983c4dc7

View File

@@ -45,7 +45,7 @@ $(document).ready(function() {
if (quantity > maxQuantity) {
quantity = maxQuantity;
save.parents('tr').find('input.line_item_quantity').val(maxQuantity);
alert('<%= I18n.t("js.admin.orders.quantity_adjusted") %>');
alert(t("js.admin.orders.quantity_adjusted"));
}
toggleItemEdit();
@@ -84,7 +84,7 @@ adjustItems = function(shipment_number, variant_id, quantity){
url += '.json';
if (new_quantity == 0) {
alert('<%= I18n.t("js.admin.orders.quantity_unchanged") %>');
alert(t("js.admin.orders.quantity_unchanged"));
} else {
$.ajax({
type: "PUT",