feat: Make patient age translateable (#24416)

* feat: Make patient age translateable

* Make patient age translatable in patient encounter

* Translate all occurrences of age calculation

* Comply to uniform translation syntax
This commit is contained in:
David Angulo
2021-01-21 20:59:16 -06:00
committed by GitHub
parent 56a8b90598
commit 3799c1a662
7 changed files with 9 additions and 9 deletions

View File

@@ -308,7 +308,7 @@ 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)')}`;
};
// List Stock items

View File

@@ -293,5 +293,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)')}`;
};

View File

@@ -43,7 +43,7 @@ frappe.ui.form.on('Patient', {
$(frm.fields_dict['age_html'].wrapper).html("");
}
if(frm.doc.dob){
$(frm.fields_dict['age_html'].wrapper).html("AGE : " + get_age(frm.doc.dob));
$(frm.fields_dict['age_html'].wrapper).html(`${__('AGE')} : ${get_age(frm.doc.dob)}`);
}
}
});
@@ -58,7 +58,7 @@ frappe.ui.form.on("Patient", "dob", function(frm) {
}
else{
var 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 {
@@ -81,7 +81,7 @@ var get_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)')}`;
};
var btn_create_vital_signs = function (frm) {

View File

@@ -58,7 +58,7 @@ class Patient(Document):
if self.dob:
born = getdate(self.dob)
age = dateutil.relativedelta.relativedelta(getdate(), born)
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

@@ -468,5 +468,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)')}`;
};

View File

@@ -311,5 +311,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)')}`;
};

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)')}`;
};