Skip to content

Commit

Permalink
MAGETWO-55900: [GitHub] Translate messages on password strength #5509 #…
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined-olha committed Sep 20, 2016
1 parent 73bf648 commit f67e598
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ define([
'jquery',
'underscore',
'uiRegistry',
'jquery/ui'
'jquery/ui',
'mage/translate'
], function ($, _, registry) {
'use strict';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ define([
'jquery',
'Magento_Ui/js/lib/validation/utils',
'Magento_Ui/js/form/element/abstract',
'Magento_Ui/js/lib/validation/validator'
'Magento_Ui/js/lib/validation/validator',
'mage/translate'
], function ($, utils, Abstract, validator) {
'use strict';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@
*/
define([
'uiComponent',
'Magento_Customer/js/customer-data'
'Magento_Customer/js/customer-data',
'mage/translate'
], function (Component, customerData) {
'use strict';

var sidebarInitialized = false;

function initSidebar() {
if (sidebarInitialized) {
return ;
return;
}
sidebarInitialized = true;
require([
'jquery',
'mage/mage'
], function ($) {
/*eslint-disable max-len*/
$('[data-role=compare-products-sidebar]').mage('compareItems', {
"removeConfirmMessage": $.mage.__(
"Are you sure you want to remove this item from your Compare Products list?"
),
"removeSelector": "#compare-items a.action.delete",
"clearAllConfirmMessage": $.mage.__(
"Are you sure you want to remove all items from your Compare Products list?"
),
"clearAllSelector": "#compare-clear-all"
'removeConfirmMessage': $.mage.__('Are you sure you want to remove this item from your Compare Products list?'),
'removeSelector': '#compare-items a.action.delete',
'clearAllConfirmMessage': $.mage.__('Are you sure you want to remove all items from your Compare Products list?'),
'clearAllSelector': '#compare-clear-all'
});

/*eslint-enable max-len*/
});
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Checkout/view/frontend/web/js/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ define([

if (msg) {
alert({
content: $.mage.__(msg)
content: msg
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ define([
'jquery',
'ko',
'underscore',
'sidebar'
'sidebar',
'mage/translate'
], function (Component, customerData, $, ko, _) {
'use strict';

Expand Down Expand Up @@ -68,9 +69,7 @@ define([
'qty': ':input.cart-item-qty',
'button': ':button.update-cart-item'
},
'confirmMessage': $.mage.__(
'Are you sure you would like to remove this item from the shopping cart?'
)
'confirmMessage': $.mage.__('Are you sure you would like to remove this item from the shopping cart?')
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ require([
'jquery',
'mage/template',
'jquery/file-uploader',
'domReady!'
'domReady!',
'mage/translate'
], function ($, mageTemplate) {
$('#<?php echo $block->getHtmlId() ?> .fileupload').fileupload({
dataType: 'json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ define([
'jquery',
'Magento_Ui/js/core/app',
'underscore',
'notification'
'notification',
'mage/translate'
], function (Component, $, bootstrap, _) {
'use strict';

Expand Down Expand Up @@ -221,9 +222,7 @@ define([

if (data.items.length) {
this.productsModal.notification('add', {
message: $.mage.__(
'Choose a new product to delete and replace the current product configuration.'
),
message: $.mage.__('Choose a new product to delete and replace the current product configuration.'),
messageContainer: this.gridSelector
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ define([
this.setNotificationMessage();
},
setNotificationMessage: function () {
/*eslint-disable max-len*/
var msg = $.mage.__('When you remove or add an attribute, we automatically update all configurations and you will need to recreate current configurations manually.');

/*eslint-enable max-len*/

if (this.mode === 'edit') {
this.wizard.setNotificationMessage($.mage.__('When you remove or add an attribute, we automatically ' +
'update all configurations and you will need to recreate current configurations manually.'));
this.wizard.setNotificationMessage(msg);
}
},
doSelectSavedAttributes: function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ require([
'mage/template',
'jquery/file-uploader',
'mage/mage',
'prototype'
'prototype',
'mage/translate'
], function(jQuery, registry, mageTemplate){
registry.get('downloadable', function (Downloadable) {
var linkTemplate = '<tr>'+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ require([
'uiRegistry',
'mage/template',
'jquery/file-uploader',
'prototype'
'prototype',
'mage/translate'
], function (jQuery, registry, mageTemplate) {
registry.get('downloadable', function (Downloadable) {
var sampleTemplate = '<tr>'+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
'Magento_Payment/js/model/credit-card-validation/credit-card-number-validator',
'Magento_Payment/js/model/credit-card-validation/expiration-date-validator/expiration-year-validator',
'Magento_Payment/js/model/credit-card-validation/expiration-date-validator/expiration-month-validator',
'Magento_Payment/js/model/credit-card-validation/credit-card-data'
'Magento_Payment/js/model/credit-card-validation/credit-card-data',
'mage/translate'
], factory);
} else {
factory(jQuery);
Expand Down Expand Up @@ -40,7 +41,7 @@
return false;
}
},
'Please enter a valid credit card type number.'
$.mage.__('Please enter a valid credit card type number.')
],
'validate-card-number': [
/**
Expand All @@ -51,7 +52,7 @@
function (number) {
return creditCardNumberValidator(number).isValid;
},
'Please enter a valid credit card number.'
$.mage.__('Please enter a valid credit card number.')
],
'validate-card-date': [
/**
Expand All @@ -62,7 +63,7 @@
function (date) {
return monthValidator(date).isValid;
},
'Incorrect credit card expiration month.'
$.mage.__('Incorrect credit card expiration month.')
],
'validate-card-cvv': [
/**
Expand All @@ -74,7 +75,7 @@
var maxLength = creditCardData.creditCard ? creditCardData.creditCard.code.size : 3;
return cvvValidator(cvv, maxLength).isValid;
},
'Please enter a valid credit card verification number.'
$.mage.__('Please enter a valid credit card verification number.')
],
'validate-card-year': [
/**
Expand All @@ -85,7 +86,7 @@
function (date) {
return monthValidator(date).isValid;
},
'Incorrect credit card expiration year.'
$.mage.__('Incorrect credit card expiration year.')
]

}, function (i, rule) {
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Paypal/view/frontend/web/order-review.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ define([
}
}
alert({
content: $.mage.__(msg)
content: msg
});
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
define([
'jquery',
'Magento_Ui/js/modal/alert',
'jquery/ui'
'jquery/ui',
'mage/translate'
], function ($, alert) {
'use strict';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* See COPYING.txt for license details.
*/
require([
'jquery'
'jquery',
'mage/translate'
], function ($) {
'use strict';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ require([
'jquery',
'mage/template',
'jquery/file-uploader',
'domReady!'
'domReady!',
'mage/translate'
], function ($, mageTemplate) {

$('#fileupload').fileupload({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ define([
'jquery',
'mage/template',
'text!Magento_Ui/templates/grid/cells/thumbnail/preview.html',
'Magento_Ui/js/modal/modal'
'Magento_Ui/js/modal/modal',
'mage/translate'
], function (Column, $, mageTemplate, thumbnailPreviewTemplate) {
'use strict';

Expand Down
20 changes: 11 additions & 9 deletions app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,10 @@ define([
var pass = $.trim(v);
var result = pass.length >= passwordMinLength;
if (result == false) {
validator.passwordErrorMessage = $.mage.__(
"Minimum length of this field must be equal or greater than %1 symbols." +
" Leading and trailing spaces will be ignored."
).replace('%1', passwordMinLength);
/*eslint-disable max-len*/
validator.passwordErrorMessage = $.mage.__('Minimum length of this field must be equal or greater than %1 symbols. Leading and trailing spaces will be ignored.').replace('%1', passwordMinLength);

/*eslint-enable max-len*/
return result;
}
if (pass.match(/\d+/)) {
Expand All @@ -450,10 +450,11 @@ define([
}
if (counter < passwordMinCharacterSets) {
result = false;
validator.passwordErrorMessage = $.mage.__(
"Minimum of different classes of characters in password is %1." +
" Classes of characters: Lower Case, Upper Case, Digits, Special Characters."
).replace('%1', passwordMinCharacterSets);

/*eslint-disable max-len*/
validator.passwordErrorMessage = $.mage.__('Minimum of different classes of characters in password is %1. Classes of characters: Lower Case, Upper Case, Digits, Special Characters.').replace('%1', passwordMinCharacterSets);

/*eslint-enable max-len*/
}
return result;
}, function () {
Expand Down Expand Up @@ -741,7 +742,8 @@ define([
}
}
return true;
}, "Please enter valid email addresses, separated by commas. For example, [email protected], [email protected]."
},
$.mage.__('Please enter valid email addresses, separated by commas. For example, [email protected], [email protected].')
],
"validate-cc-number": [
/**
Expand Down
27 changes: 12 additions & 15 deletions lib/web/mage/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,10 @@
var pass = $.trim(v);
var result = pass.length >= passwordMinLength;
if (result == false) {
validator.passwordErrorMessage = $.mage.__(
"Minimum length of this field must be equal or greater than %1 symbols." +
" Leading and trailing spaces will be ignored."
).replace('%1', passwordMinLength);
/*eslint-disable max-len*/
validator.passwordErrorMessage = $.mage.__('Minimum length of this field must be equal or greater than %1 symbols. Leading and trailing spaces will be ignored.').replace('%1', passwordMinLength);

/*eslint-enable max-len*/
return result;
}
if (pass.match(/\d+/)) {
Expand All @@ -565,10 +565,11 @@
}
if (counter < passwordMinCharacterSets) {
result = false;
validator.passwordErrorMessage = $.mage.__(
"Minimum of different classes of characters in password is %1." +
" Classes of characters: Lower Case, Upper Case, Digits, Special Characters."
).replace('%1', passwordMinCharacterSets);

/*eslint-disable max-len*/
validator.passwordErrorMessage = $.mage.__('Minimum of different classes of characters in password is %1. Classes of characters: Lower Case, Upper Case, Digits, Special Characters.').replace('%1', passwordMinCharacterSets);

/*eslint-enable max-len*/
}
return result;
}, function () {
Expand Down Expand Up @@ -984,7 +985,7 @@

return !!container.querySelectorAll(selector).length;
},
'Please select one of the options.'
$.mage.__('Please select one of the options.')
],
"less-than-equals-to": [
function (value, element, params) {
Expand Down Expand Up @@ -1145,16 +1146,12 @@
if (name.match(reMax) && result) {
length = name.split('-')[2];
result = (v.length <= length);
validator.validateMessage = $.mage.__(
"Please enter less or equal than %1 symbols."
).replace('%1', length);
validator.validateMessage = $.mage.__('Please enter less or equal than %1 symbols.').replace('%1', length);
}
if (name.match(reMin) && result && !$.mage.isEmpty(v)) {
length = name.split('-')[2];
result = v.length >= length;
validator.validateMessage = $.mage.__(
"Please enter more or equal than %1 symbols."
).replace('%1', length);
validator.validateMessage = $.mage.__('Please enter more or equal than %1 symbols.').replace('%1', length);
}
});
return result;
Expand Down

1 comment on commit f67e598

@radulff
Copy link

@radulff radulff commented on f67e598 Jun 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any other way to achieve all this changes by not modifying Magento folders? I mainly need the changes from:

app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js

lib/web/mage/validation.js

I can apply the change modifying the lib folder but, as I asked, I can't modify the Magento folder as itself. We use extensions as submodules on git to override Magento Folders.

Please sign in to comment.