refactor: added missing translation functions (#18143)

* fix: Translating Error and Messages

* Update erpnext/controllers/item_variant.py

Co-Authored-By: Shivam Mishra <scmmishra@users.noreply.github.com>

* Update erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py

Co-Authored-By: Shivam Mishra <scmmishra@users.noreply.github.com>
This commit is contained in:
Anurag Mishra
2019-07-03 15:15:08 +05:30
committed by Shivam Mishra
parent 8929c62113
commit 841d852f41
20 changed files with 41 additions and 36 deletions

View File

@@ -38,7 +38,7 @@ class Question(Document):
options = self.options
answers = [item.name for item in options if item.is_correct == True]
if len(answers) == 0:
frappe.throw("No correct answer is set for {0}".format(self.name))
frappe.throw(_("No correct answer is set for {0}".format(self.name)))
return None
elif len(answers) == 1:
return answers[0]

View File

@@ -4,12 +4,13 @@
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.model.document import Document
class Quiz(Document):
def validate(self):
if self.passing_score > 100:
frappe.throw("Passing Score value should be between 0 and 100")
frappe.throw(_("Passing Score value should be between 0 and 100"))
def allowed_attempt(self, enrollment, quiz_name):
if self.max_attempts == 0:
@@ -17,7 +18,7 @@ class Quiz(Document):
try:
if len(frappe.get_all("Quiz Activity", {'enrollment': enrollment.name, 'quiz': quiz_name})) >= self.max_attempts:
frappe.msgprint("Maximum attempts for this quiz reached!")
frappe.msgprint(_("Maximum attempts for this quiz reached!"))
return False
else:
return True
@@ -56,5 +57,5 @@ def compare_list_elementwise(*args):
else:
return False
except TypeError:
frappe.throw("Compare List function takes on list arguments")
frappe.throw(_("Compare List function takes on list arguments"))

View File

@@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe, json
from frappe import _
from frappe.model.document import Document
from erpnext.education.api import get_grade
from frappe.utils.pdf import get_pdf
@@ -79,7 +80,7 @@ def get_attendance_count(student, academic_year, academic_term=None):
from_date, to_date = frappe.db.get_value("Academic Term", academic_term, ["term_start_date", "term_end_date"])
if from_date and to_date:
attendance = dict(frappe.db.sql('''select status, count(student) as no_of_days
from `tabStudent Attendance` where student = %s
from `tabStudent Attendance` where student = %s
and date between %s and %s group by status''',
(student, from_date, to_date)))
if "Absent" not in attendance.keys():
@@ -88,4 +89,4 @@ def get_attendance_count(student, academic_year, academic_term=None):
attendance["Present"] = 0
return attendance
else:
frappe.throw("Provide the academic year and set the starting and ending date.")
frappe.throw(_("Provide the academic year and set the starting and ending date."))

View File

@@ -148,7 +148,7 @@ def enroll_in_program(program_name, student=None):
# Check if self enrollment in allowed
program = frappe.get_doc('Program', program_name)
if not program.allow_self_enroll:
return frappe.throw("You are not allowed to enroll for this course")
return frappe.throw(_("You are not allowed to enroll for this course"))
student = get_current_student()
if not student:
@@ -162,7 +162,7 @@ def enroll_in_program(program_name, student=None):
# Check if self enrollment in allowed
program = frappe.get_doc('Program', program_name)
if not program.allow_self_enroll:
return frappe.throw("You are not allowed to enroll for this course")
return frappe.throw(_("You are not allowed to enroll for this course"))
# Enroll in program
program_enrollment = student.enroll_in_program(program_name)
@@ -185,7 +185,7 @@ def add_activity(course, content_type, content, program):
student = get_current_student()
if not student:
return frappe.throw("Student with email {0} does not exist".format(frappe.session.user), frappe.DoesNotExistError)
return frappe.throw(_("Student with email {0} does not exist".format(frappe.session.user)), frappe.DoesNotExistError)
enrollment = get_or_create_course_enrollment(course, program)
if content_type == 'Quiz':
@@ -220,7 +220,7 @@ def get_quiz(quiz_name, course):
quiz = frappe.get_doc("Quiz", quiz_name)
questions = quiz.get_questions()
except:
frappe.throw("Quiz {0} does not exist".format(quiz_name))
frappe.throw(_("Quiz {0} does not exist".format(quiz_name)))
return None
questions = [{
@@ -347,7 +347,7 @@ def get_or_create_course_enrollment(course, program):
if not course_enrollment:
program_enrollment = get_enrollment('program', program, student.name)
if not program_enrollment:
frappe.throw("You are not enrolled in program {0}".format(program))
frappe.throw(_("You are not enrolled in program {0}".format(program)))
return
return student.enroll_in_course(course_name=course, program_enrollment=get_enrollment('program', program, student.name))
else: