From 06983c4dc7c507a03b17424802c1808d255fcf36 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 27 Jan 2021 14:12:25 +1100 Subject: [PATCH] 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. --- .../admin/spree/orders/variant_autocomplete.js.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/admin/spree/orders/variant_autocomplete.js.erb b/app/assets/javascripts/admin/spree/orders/variant_autocomplete.js.erb index 0bc4ba3f927..060b212da70 100644 --- a/app/assets/javascripts/admin/spree/orders/variant_autocomplete.js.erb +++ b/app/assets/javascripts/admin/spree/orders/variant_autocomplete.js.erb @@ -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",