Revert "fix: changed translate entries to javascript rather than python to resolve semgrep linter translate checks"

This reverts commit 2b51641799.
This commit is contained in:
Gavin D'souza 2021-06-10 16:27:59 +05:30
parent 2b51641799
commit df6c5cd3e2

View file

@ -21,7 +21,7 @@ login.bind_events = function () {
args.pwd = $("#login_password").val();
args.device = "desktop";
if (!args.usr || !args.pwd) {
frappe.msgprint(__("Both login and password required"));
frappe.msgprint('{{ _("Both login and password required") }}');
return false;
}
login.call(args);
@ -36,7 +36,7 @@ login.bind_events = function () {
args.redirect_to = frappe.utils.sanitise_redirect(frappe.utils.get_url_arg("redirect-to"));
args.full_name = frappe.utils.xss_sanitise(($("#signup_fullname").val() || "").trim());
if (!args.email || !validate_email(args.email) || !args.full_name) {
login.set_status(__("Valid email and name required"), 'red');
login.set_status('{{ _("Valid email and name required") }}', 'red');
return false;
}
login.call(args);
@ -49,7 +49,7 @@ login.bind_events = function () {
args.cmd = "frappe.core.doctype.user.user.reset_password";
args.user = ($("#forgot_email").val() || "").trim();
if (!args.user) {
login.set_status(__("Valid Login id required."), 'red');
login.set_status('{{ _("Valid Login id required.") }}', 'red');
return false;
}
login.call(args);
@ -60,10 +60,10 @@ login.bind_events = function () {
var input = $($(this).attr("toggle"));
if (input.attr("type") == "password") {
input.attr("type", "text");
$(this).text(__("Hide"))
$(this).text('{{ _("Hide") }}')
} else {
input.attr("type", "password");
$(this).text(__("Show"))
$(this).text('{{ _("Show") }}')
}
});
@ -75,7 +75,7 @@ login.bind_events = function () {
args.pwd = $("#login_password").val();
args.device = "desktop";
if (!args.usr || !args.pwd) {
login.set_status(__("Both login and password required"), 'red');
login.set_status('{{ _("Both login and password required") }}', 'red');
return false;
}
login.call(args);
@ -136,7 +136,7 @@ login.signup = function () {
// Login
login.call = function (args, callback) {
login.set_status(__("Verifying..."), 'blue');
login.set_status('{{ _("Verifying...") }}', 'blue');
return frappe.call({
type: "POST",
@ -194,7 +194,7 @@ login.login_handlers = (function () {
var login_handlers = {
200: function (data) {
if (data.message == 'Logged In') {
login.set_status(__("Success"), 'green');
login.set_status('{{ _("Success") }}', 'green');
window.location.href = frappe.utils.sanitise_redirect(frappe.utils.get_url_arg("redirect-to")) || data.home_page;
} else if (data.message == 'Password Reset') {
window.location.href = frappe.utils.sanitise_redirect(data.redirect_to);
@ -218,13 +218,13 @@ login.login_handlers = (function () {
}
} else if (window.location.hash === '#forgot') {
if (data.message === 'not found') {
login.set_status(__("Not a valid user"), 'red');
login.set_status('{{ _("Not a valid user") }}', 'red');
} else if (data.message == 'not allowed') {
login.set_status(__("Not Allowed"), 'red');
login.set_status('{{ _("Not Allowed") }}', 'red');
} else if (data.message == 'disabled') {
login.set_status(__("Not Allowed: Disabled User"), 'red');
login.set_status('{{ _("Not Allowed: Disabled User") }}', 'red');
} else {
login.set_status(__("Instructions Emailed"), 'green');
login.set_status('{{ _("Instructions Emailed") }}', 'green');
}
@ -232,7 +232,7 @@ login.login_handlers = (function () {
if (cint(data.message[0]) == 0) {
login.set_status(data.message[1], 'red');
} else {
login.set_status(__("Success"), 'green');
login.set_status('{{ _("Success") }}', 'green');
frappe.msgprint(data.message[1])
}
//login.set_status(__(data.message), 'green');
@ -240,7 +240,7 @@ login.login_handlers = (function () {
//OTP verification
if (data.verification && data.message != 'Logged In') {
login.set_status(__("Success"), 'green');
login.set_status('{{ _("Success") }}', 'green');
document.cookie = "tmp_id=" + data.tmp_id;
@ -253,8 +253,8 @@ login.login_handlers = (function () {
}
}
},
401: get_error_handler(__("Invalid Login. Try again.")),
417: get_error_handler(__("Oops! Something went wrong"))
401: get_error_handler('{{ _("Invalid Login. Try again.") }}'),
417: get_error_handler('{{ _("Oops! Something went wrong") }}')
};
return login_handlers;
@ -282,7 +282,7 @@ var verify_token = function (event) {
args.otp = $("#login_token").val();
args.tmp_id = frappe.get_cookie('tmp_id');
if (!args.otp) {
frappe.msgprint(__("Login token required"));
frappe.msgprint('{{ _("Login token required") }}');
return false;
}
login.call(args);
@ -292,17 +292,9 @@ var verify_token = function (event) {
var request_otp = function (r) {
$('.login-content').empty();
$('.login-content:visible').append($('<div>').attr({ 'id': 'twofactor_div' }).html(
'<form class="form-verify">\
<div class="page-card-head">\
<span class="indicator blue" data-text="Verification">{{ _("Verification") }}</span>\
</div>\
<div id="otp_div"></div>\
<input type="text" id="login_token" autocomplete="off" class="form-control" placeholder={{ _("Verification Code") }} required="" autofocus="">\
<button class="btn btn-sm btn-primary btn-block" id="verify_token">{{ _("Verify") }}</button>\
</form>'));
// add event handler for submit button
verify_token();
$('.login-content:visible').append($('<div>').attr({ 'id': 'twofactor_div' }).html('{{ _("Verification") }}<input type="text" id="login_token" autocomplete="off" class="form-control" placeholder={{ _("Verification Code") }} required="" autofocus="">{{ _("Verify") }}'));
// add event handler for submit button
verify_token();
}
var continue_otp_app = function (setup, qrcode) {
@ -310,11 +302,11 @@ var continue_otp_app = function (setup, qrcode) {
var qrcode_div = $('<div class="text-muted" style="padding-bottom: 15px;"></div>');
if (setup) {
direction = $('<div>').attr('id', 'qr_info').text(__("Enter Code displayed in OTP App."));
direction = $('<div>').attr('id', 'qr_info').text('{{ _("Enter Code displayed in OTP App.") }}');
qrcode_div.append(direction);
$('#otp_div').prepend(qrcode_div);
} else {
direction = $('<div>').attr('id', 'qr_info').text(__("OTP setup using OTP App was not completed. Please contact Administrator."));
direction = $('<div>').attr('id', 'qr_info').text('{{ _("OTP setup using OTP App was not completed. Please contact Administrator.") }}');
qrcode_div.append(direction);
$('#otp_div').prepend(qrcode_div);
}
@ -328,7 +320,7 @@ var continue_sms = function (setup, prompt) {
sms_div.append(prompt)
$('#otp_div').prepend(sms_div);
} else {
direction = $('<div>').attr('id', 'qr_info').text(prompt || __("SMS was not sent. Please contact Administrator."));
direction = $('<div>').attr('id', 'qr_info').text(prompt || '{{ _("SMS was not sent. Please contact Administrator.") }}');
sms_div.append(direction);
$('#otp_div').prepend(sms_div)
}
@ -342,7 +334,7 @@ var continue_email = function (setup, prompt) {
email_div.append(prompt)
$('#otp_div').prepend(email_div);
} else {
var direction = $('<div>').attr('id', 'qr_info').text(prompt || __("Verification code email not sent. Please contact Administrator."));
var direction = $('<div>').attr('id', 'qr_info').text(prompt || '{{ _("Verification code email not sent. Please contact Administrator.") }}');
email_div.append(direction);
$('#otp_div').prepend(email_div);
}