From 3dcd4f3682633a609ae5c6b3c635a6fa60362a95 Mon Sep 17 00:00:00 2001 From: saurabh Date: Wed, 17 Feb 2016 19:16:12 +0530 Subject: [PATCH] created new file --- .../public/js/controllers/load_languages.js | 15 ++ erpnext/setup/doctype/translation/__init__.py | 0 .../doctype/translation/test_translation.py | 12 ++ .../setup/doctype/translation/translation.js | 12 ++ .../doctype/translation/translation.json | 175 ++++++++++++++++++ .../setup/doctype/translation/translation.py | 11 ++ .../doctype/translation_fields/__init__.py | 0 .../translation_fields.json | 105 +++++++++++ .../translation_fields/translation_fields.py | 10 + 9 files changed, 340 insertions(+) create mode 100644 erpnext/public/js/controllers/load_languages.js create mode 100644 erpnext/setup/doctype/translation/__init__.py create mode 100644 erpnext/setup/doctype/translation/test_translation.py create mode 100644 erpnext/setup/doctype/translation/translation.js create mode 100644 erpnext/setup/doctype/translation/translation.json create mode 100644 erpnext/setup/doctype/translation/translation.py create mode 100644 erpnext/setup/doctype/translation_fields/__init__.py create mode 100644 erpnext/setup/doctype/translation_fields/translation_fields.json create mode 100644 erpnext/setup/doctype/translation_fields/translation_fields.py diff --git a/erpnext/public/js/controllers/load_languages.js b/erpnext/public/js/controllers/load_languages.js new file mode 100644 index 0000000000..e4de2639bb --- /dev/null +++ b/erpnext/public/js/controllers/load_languages.js @@ -0,0 +1,15 @@ +frappe.provide("erpnext") + +cur_frm.cscript.before_load = function(doc, dt, dn, callback) { + var update_language_select = function(user_language) { + cur_frm.set_df_property("language", "options", frappe.languages || ["", "English"]); + callback && callback(); + } + + if(!frappe.languages) { + frappe.languages = frappe.boot.languages; + update_language_select(); + } else { + update_language_select(); + } +} diff --git a/erpnext/setup/doctype/translation/__init__.py b/erpnext/setup/doctype/translation/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/setup/doctype/translation/test_translation.py b/erpnext/setup/doctype/translation/test_translation.py new file mode 100644 index 0000000000..61adef2eab --- /dev/null +++ b/erpnext/setup/doctype/translation/test_translation.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +# test_records = frappe.get_test_records('Translation') + +class TestTranslation(unittest.TestCase): + pass diff --git a/erpnext/setup/doctype/translation/translation.js b/erpnext/setup/doctype/translation/translation.js new file mode 100644 index 0000000000..27c818ab3f --- /dev/null +++ b/erpnext/setup/doctype/translation/translation.js @@ -0,0 +1,12 @@ +frappe.require("assets/erpnext/js/controllers/load_languages.js"); + +frappe.ui.form.on('Translation', { + language: function(frm, cdt, cdn) { + frm.cscript.update_language_code(frm) + } +}); + +cur_frm.cscript.update_language_code = function(frm){ + var doc = frm.doc; + frm.set_value('language_code', frappe.boot.lang_dict[doc.language]) +} diff --git a/erpnext/setup/doctype/translation/translation.json b/erpnext/setup/doctype/translation/translation.json new file mode 100644 index 0000000000..11e555d25d --- /dev/null +++ b/erpnext/setup/doctype/translation/translation.json @@ -0,0 +1,175 @@ +{ + "allow_copy": 0, + "allow_import": 1, + "allow_rename": 0, + "autoname": "", + "creation": "2016-02-17 12:21:16.175465", + "custom": 0, + "docstatus": 0, + "doctype": "DocType", + "document_type": "Setup", + "fields": [ + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "language", + "fieldtype": "Select", + "hidden": 0, + "ignore_user_permissions": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Language", + "length": 0, + "no_copy": 0, + "options": "Loading...", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "source_name", + "fieldtype": "Small Text", + "hidden": 0, + "ignore_user_permissions": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Source Name", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "target_name", + "fieldtype": "Small Text", + "hidden": 0, + "ignore_user_permissions": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Translated", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "column_break_3", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "in_filter": 0, + "in_list_view": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "language_code", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "in_filter": 0, + "in_list_view": 1, + "label": "Language Code", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + } + ], + "hide_heading": 0, + "hide_toolbar": 0, + "idx": 0, + "in_create": 0, + "in_dialog": 0, + "is_submittable": 0, + "issingle": 0, + "istable": 0, + "max_attachments": 0, + "modified": "2016-02-17 15:43:56.789862", + "modified_by": "Administrator", + "module": "Setup", + "name": "Translation", + "name_case": "", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "apply_user_permissions": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "set_user_permissions": 0, + "share": 1, + "submit": 0, + "write": 1 + } + ], + "read_only": 0, + "read_only_onload": 0, + "sort_field": "modified", + "sort_order": "DESC", + "title_field": "source_name" +} \ No newline at end of file diff --git a/erpnext/setup/doctype/translation/translation.py b/erpnext/setup/doctype/translation/translation.py new file mode 100644 index 0000000000..7e529e0c18 --- /dev/null +++ b/erpnext/setup/doctype/translation/translation.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.model.document import Document + +class Translation(Document): + def on_update(self): + frappe.cache().hdel('lang_user_translations', self.language_code) diff --git a/erpnext/setup/doctype/translation_fields/__init__.py b/erpnext/setup/doctype/translation_fields/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/setup/doctype/translation_fields/translation_fields.json b/erpnext/setup/doctype/translation_fields/translation_fields.json new file mode 100644 index 0000000000..42ae70d944 --- /dev/null +++ b/erpnext/setup/doctype/translation_fields/translation_fields.json @@ -0,0 +1,105 @@ +{ + "allow_copy": 0, + "allow_import": 0, + "allow_rename": 0, + "autoname": "", + "creation": "2016-02-17 12:19:52.405961", + "custom": 0, + "docstatus": 0, + "doctype": "DocType", + "document_type": "Setup", + "fields": [ + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "language_code", + "fieldtype": "Data", + "hidden": 1, + "ignore_user_permissions": 0, + "in_filter": 0, + "in_list_view": 1, + "label": "Language Code", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "source_name", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "in_filter": 0, + "in_list_view": 1, + "label": "Source Name", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "target_name", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "in_filter": 0, + "in_list_view": 1, + "label": "Target Name", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + } + ], + "hide_heading": 0, + "hide_toolbar": 0, + "idx": 0, + "in_create": 0, + "in_dialog": 0, + "is_submittable": 0, + "issingle": 0, + "istable": 1, + "max_attachments": 0, + "modified": "2016-02-17 13:24:07.227273", + "modified_by": "Administrator", + "module": "Setup", + "name": "Translation Fields", + "name_case": "", + "owner": "Administrator", + "permissions": [], + "read_only": 0, + "read_only_onload": 0, + "sort_field": "modified", + "sort_order": "DESC" +} \ No newline at end of file diff --git a/erpnext/setup/doctype/translation_fields/translation_fields.py b/erpnext/setup/doctype/translation_fields/translation_fields.py new file mode 100644 index 0000000000..fcd4204715 --- /dev/null +++ b/erpnext/setup/doctype/translation_fields/translation_fields.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.model.document import Document + +class TranslationFields(Document): + pass