Selaa lähdekoodia

Updated build_from_query_reports to generate locale from labels , query and also from js and py files

version-14
Syed Qadeer 11 vuotta sitten
vanhempi
commit
694b631ff1
1 muutettua tiedostoa jossa 25 lisäystä ja 5 poistoa
  1. +25
    -5
      webnotes/translate.py

+ 25
- 5
webnotes/translate.py Näytä tiedosto

@@ -130,16 +130,36 @@ def build_for_pages(path):
write_messages_file(basepath, messages_py, "py")
def build_from_query_report():
"""make locale for the framework report titles"""
for item in webnotes.conn.sql("""select report_name,ref_doctype from `tabReport`""", as_dict=1):
messages = []
"""make locale for the query reports from database and the framework js and py files"""
import re
for item in webnotes.conn.sql("""select report_name,ref_doctype,query from `tabReport`""", as_dict=1):
messages_js, messages_py = [], []

if item:
messages.append(item.report_name)
messages_js.append(item.report_name)
messages_py.append(item.report_name)
# get the messages from the query using the regex :
# if we have the string "Production Date:Date:180" in the query then the regex will search for string between " and : .
# the regex will take "Production Date" and store them into messages
if item.query :
messages_query = re.findall('"([^:,^"]*):', item.query)
messages_js += messages_query
messages_py += messages_query
module = get_doctype_module(item.ref_doctype)
if module :
doctype_path = get_doc_path(module, "Report", item.report_name)
write_messages_file(doctype_path, messages, 'js')
if os.path.exists(doctype_path):
for (basepath, folders, files) in os.walk(doctype_path):
for fname in files:
if fname.endswith('.js'):
messages_js += get_message_list(os.path.join(basepath, fname))
if fname.endswith('.py'):
messages_py += get_message_list(os.path.join(basepath, fname))
break
write_messages_file(doctype_path, messages_js, 'js')
write_messages_file(doctype_path, messages_py, 'py')


def build_from_database():
"""make doctype labels, names, options, descriptions"""


Ladataan…
Peruuta
Tallenna