Merge pull request #24464 from sgtpepper9907/feat-make-patient-age-translateable

feat: Make patient age translateable
This commit is contained in:
Marica 2021-03-10 10:15:38 +05:30 committed by GitHub
commit 6ccd64c2ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 10 deletions

View File

@ -364,7 +364,7 @@ let calculate_age = function(birth) {
let age = new Date();
age.setTime(ageMS);
let years = age.getFullYear() - 1970;
return years + ' Year(s) ' + age.getMonth() + ' Month(s) ' + age.getDate() + ' Day(s)';
return `${years} ${__('Years(s)')} ${age.getMonth()} ${__('Month(s)')} ${age.getDate()} ${__('Day(s)')}`;
};
// List Stock items

View File

@ -258,5 +258,5 @@ var calculate_age = function (dob) {
var age = new Date();
age.setTime(ageMS);
var years = age.getFullYear() - 1970;
return years + ' Year(s) ' + age.getMonth() + ' Month(s) ' + age.getDate() + ' Day(s)';
return `${years} ${__('Years(s)')} ${age.getMonth()} ${__('Month(s)')} ${age.getDate()} ${__('Day(s)')}`;
};

View File

@ -46,11 +46,11 @@ frappe.ui.form.on('Patient', {
}
},
onload: function (frm) {
if(!frm.doc.dob){
if (!frm.doc.dob) {
$(frm.fields_dict['age_html'].wrapper).html('');
}
if(frm.doc.dob){
$(frm.fields_dict['age_html'].wrapper).html('AGE : ' + get_age(frm.doc.dob));
if (frm.doc.dob) {
$(frm.fields_dict['age_html'].wrapper).html(`${__('AGE')} : ${get_age(frm.doc.dob)}`);
}
}
});
@ -65,7 +65,7 @@ frappe.ui.form.on('Patient', 'dob', function(frm) {
}
else {
let age_str = get_age(frm.doc.dob);
$(frm.fields_dict['age_html'].wrapper).html('AGE : ' + age_str);
$(frm.fields_dict['age_html'].wrapper).html(`${__('AGE')} : ${age_str}`);
}
}
else {

View File

@ -108,7 +108,7 @@ class Patient(Document):
if self.dob:
dob = getdate(self.dob)
age = dateutil.relativedelta.relativedelta(getdate(), dob)
age_str = str(age.years) + ' year(s) ' + str(age.months) + ' month(s) ' + str(age.days) + ' day(s)'
age_str = str(age.years) + ' ' + _("Years(s)") + ' ' + str(age.months) + ' ' + _("Month(s)") + ' ' + str(age.days) + ' ' + _("Day(s)")
return age_str
def invoice_patient_registration(self):

View File

@ -596,5 +596,5 @@ let calculate_age = function(birth) {
let age = new Date();
age.setTime(ageMS);
let years = age.getFullYear() - 1970;
return years + ' Year(s) ' + age.getMonth() + ' Month(s) ' + age.getDate() + ' Day(s)';
return `${years} ${__('Years(s)')} ${age.getMonth()} ${__('Month(s)')} ${age.getDate()} ${__('Day(s)')}`;
};

View File

@ -358,5 +358,5 @@ let calculate_age = function(birth) {
let age = new Date();
age.setTime(ageMS);
let years = age.getFullYear() - 1970;
return years + ' Year(s) ' + age.getMonth() + ' Month(s) ' + age.getDate() + ' Day(s)';
return `${years} ${__('Years(s)')} ${age.getMonth()} ${__('Month(s)')} ${age.getDate()} ${__('Day(s)')}`;
};

View File

@ -36,5 +36,5 @@ var calculate_age = function(birth) {
var age = new Date();
age.setTime(ageMS);
var years = age.getFullYear() - 1970;
return years + ' Year(s) ' + age.getMonth() + ' Month(s) ' + age.getDate() + ' Day(s)';
return `${years} ${__('Years(s)')} ${age.getMonth()} ${__('Month(s)')} ${age.getDate()} ${__('Day(s)')}`;
};