def execute(): language = frappe.db.get_value('System Settings', None, 'language') if language: system_settings = frappe.get_doc('System Settings', 'System Settings') if get_lang_dict().get(language, language) != system_settings.language: system_settings.language = get_lang_dict().get(language, language) system_settings.flags.ignore_mandatory=True system_settings.save() for user in frappe.get_all('User', fields=['name', 'language']): if user.language: frappe.db.set_value('User', user.name, 'language', get_lang_dict().get(user.language, user.language), update_modified=False)
def get_bootinfo(): """build and return boot info""" frappe.set_user_lang(frappe.session.user) bootinfo = frappe._dict() hooks = frappe.get_hooks() doclist = [] # user get_user(bootinfo) # system info bootinfo.sysdefaults = frappe.defaults.get_defaults() bootinfo.server_date = frappe.utils.nowdate() if frappe.session['user'] != 'Guest': bootinfo.user_info = get_fullnames() bootinfo.sid = frappe.session['sid'] bootinfo.modules = {} bootinfo.module_list = [] load_desktop_icons(bootinfo) bootinfo.letter_heads = get_letter_heads() bootinfo.active_domains = frappe.get_active_domains() bootinfo.all_domains = [d.get("name") for d in frappe.get_all("Domain")] bootinfo.module_app = frappe.local.module_app bootinfo.single_types = frappe.db.sql_list("""select name from tabDocType where issingle=1""") add_home_page(bootinfo, doclist) bootinfo.page_info = get_allowed_pages() load_translations(bootinfo) add_timezone_info(bootinfo) load_conf_settings(bootinfo) load_print(bootinfo, doclist) doclist.extend(get_meta_bundle("Page")) bootinfo.home_folder = frappe.db.get_value("File", {"is_home_folder": 1}) # ipinfo if frappe.session.data.get('ipinfo'): bootinfo.ipinfo = frappe.session['data']['ipinfo'] # add docs bootinfo.docs = doclist for method in hooks.boot_session or []: frappe.get_attr(method)(bootinfo) if bootinfo.lang: bootinfo.lang = unicode(bootinfo.lang) bootinfo.versions = {k: v['version'] for k, v in get_versions().items()} bootinfo.error_report_email = frappe.get_hooks("error_report_email") bootinfo.calendars = sorted(frappe.get_hooks("calendars")) bootinfo.treeviews = frappe.get_hooks("treeviews") or [] bootinfo.lang_dict = get_lang_dict() bootinfo.feedback_triggers = get_enabled_feedback_trigger() bootinfo.gsuite_enabled = get_gsuite_status() bootinfo.update(get_email_accounts(user=frappe.session.user)) return bootinfo
def load_messages(language): lang = get_lang_dict()[language] frappe.local.lang = lang m = get_dict("page", "setup-wizard") m.update(get_dict("boot")) frappe.local.response["__messages"] = m return lang
def load_messages(language): frappe.clear_cache() lang = get_lang_dict()[language] frappe.local.lang = lang m = get_dict("page", "setup-wizard") m.update(get_dict("boot")) send_translations(m) return lang
def get_languages(): from frappe.translate import get_lang_dict import pytz languages = get_lang_dict().keys() languages.sort() return { "languages": [""] + languages, "timezones": pytz.all_timezones }
def get_bootinfo(): """build and return boot info""" frappe.set_user_lang(frappe.session.user) bootinfo = frappe._dict() hooks = frappe.get_hooks() doclist = [] # user get_user(bootinfo) # system info bootinfo.sysdefaults = frappe.defaults.get_defaults() bootinfo.server_date = frappe.utils.nowdate() if frappe.session['user'] != 'Guest': bootinfo.user_info = get_fullnames() bootinfo.sid = frappe.session['sid']; bootinfo.modules = {} bootinfo.module_list = [] load_desktop_icons(bootinfo) bootinfo.module_app = frappe.local.module_app bootinfo.single_types = frappe.db.sql_list("""select name from tabDocType where issingle=1""") add_home_page(bootinfo, doclist) bootinfo.page_info = get_allowed_pages() load_translations(bootinfo) add_timezone_info(bootinfo) load_conf_settings(bootinfo) load_print(bootinfo, doclist) doclist.extend(get_meta_bundle("Page")) bootinfo.home_folder = frappe.db.get_value("File", {"is_home_folder": 1}) # ipinfo if frappe.session.data.get('ipinfo'): bootinfo.ipinfo = frappe.session['data']['ipinfo'] # add docs bootinfo.docs = doclist for method in hooks.boot_session or []: frappe.get_attr(method)(bootinfo) if bootinfo.lang: bootinfo.lang = unicode(bootinfo.lang) bootinfo.versions = {k: v['version'] for k, v in get_versions().items()} bootinfo.error_report_email = frappe.get_hooks("error_report_email") bootinfo.calendars = sorted(frappe.get_hooks("calendars")) bootinfo.treeviews = frappe.get_hooks("treeviews") or [] bootinfo.email_accounts = frappe.get_all('User Emails', fields=['email_account', 'email_id'], filters=dict(parent=frappe.session.user), order_by='idx') bootinfo.lang_dict = get_lang_dict() return bootinfo
def set_user_lang(user, user_language=None): from frappe.translate import get_lang_dict if not user_language: user_language = db.get_value("Profile", user, "language") if user_language: lang_dict = get_lang_dict() if user_language in lang_dict: local.lang = lang_dict[user_language]
def get_bootinfo(): """build and return boot info""" frappe.set_user_lang(frappe.session.user) bootinfo = frappe._dict() hooks = frappe.get_hooks() doclist = [] # user get_user(bootinfo) # system info bootinfo['sysdefaults'] = frappe.defaults.get_defaults() bootinfo['server_date'] = frappe.utils.nowdate() if frappe.session['user'] != 'Guest': bootinfo['user_info'] = get_fullnames() bootinfo['sid'] = frappe.session['sid'] bootinfo.modules = {} bootinfo.module_list = [] load_desktop_icons(bootinfo) bootinfo.module_app = frappe.local.module_app bootinfo.single_types = frappe.db.sql_list( """select name from tabDocType where issingle=1""") add_home_page(bootinfo, doclist) bootinfo.page_info = get_allowed_pages() load_translations(bootinfo) add_timezone_info(bootinfo) load_conf_settings(bootinfo) load_print(bootinfo, doclist) doclist.extend(get_meta_bundle("Page")) bootinfo.home_folder = frappe.db.get_value("File", {"is_home_folder": 1}) # ipinfo if frappe.session['data'].get('ipinfo'): bootinfo['ipinfo'] = frappe.session['data']['ipinfo'] # add docs bootinfo['docs'] = doclist for method in hooks.boot_session or []: frappe.get_attr(method)(bootinfo) if bootinfo.lang: bootinfo.lang = unicode(bootinfo.lang) bootinfo['versions'] = {k: v['version'] for k, v in get_versions().items()} bootinfo.error_report_email = frappe.get_hooks("error_report_email") bootinfo.calendars = sorted(frappe.get_hooks("calendars")) bootinfo["lang_dict"] = get_lang_dict() return bootinfo
def get_languages(): from frappe.translate import get_lang_dict import pytz languages = get_lang_dict().keys() languages.sort() #hotfix, only open languages when needed return { #"languages": [""] + languages, "languages": ["english",u"中国(简体)"], "timezones": pytz.all_timezones }
def load(): if not "System Manager" in frappe.get_roles(): frappe.throw(_("Not permitted"), frappe.PermissionError) all_defaults = frappe.db.get_defaults() defaults = {} for df in frappe.get_meta("System Settings").get("fields"): if df.fieldtype in ("Select", "Data"): defaults[df.fieldname] = all_defaults.get(df.fieldname) languages = get_lang_dict().keys() languages.sort() return {"timezones": get_all_timezones(), "languages": [""] + languages, "defaults": defaults}
def execute(): frappe.reload_doc('core', 'doctype', 'language') from frappe.core.doctype.language.language import sync_languages sync_languages() # move language from old style to new style for old accounts # i.e. from "english" to "en" lang_dict = get_lang_dict() language = frappe.db.get_value('System Settings', None, 'language') if language: frappe.db.set_value('System Settings', None, 'language', lang_dict.get('language') or 'en') for user in frappe.get_all('User', fields=['name', 'language']): if user.language: frappe.db.set_value('User', user.name, 'language', lang_dict.get('language') or 'en', update_modified=False)
def load(): if not "System Manager" in frappe.get_roles(): frappe.throw(_("Not permitted"), frappe.PermissionError) all_defaults = frappe.db.get_defaults() defaults = {} for df in frappe.get_meta("System Settings").get("fields"): if df.fieldtype in ("Select", "Data"): defaults[df.fieldname] = all_defaults.get(df.fieldname) languages = get_lang_dict().keys() languages.sort() return { "timezones": get_all_timezones(), "languages": [""] + languages, "defaults": defaults }
def load_languages(): return { "default_language": get_language_from_code(frappe.local.lang), "languages": sorted(get_lang_dict().keys()) }
def get_bootinfo(): """build and return boot info""" frappe.set_user_lang(frappe.session.user) bootinfo = frappe._dict() hooks = frappe.get_hooks() doclist = [] # user get_user(bootinfo) # system info bootinfo.sitename = frappe.local.site bootinfo.sysdefaults = frappe.defaults.get_defaults() bootinfo.server_date = frappe.utils.nowdate() if frappe.session['user'] != 'Guest': bootinfo.user_info = get_user_info() bootinfo.sid = frappe.session['sid'] bootinfo.modules = {} bootinfo.module_list = [] load_desktop_data(bootinfo) bootinfo.letter_heads = get_letter_heads() bootinfo.active_domains = frappe.get_active_domains() bootinfo.all_domains = [d.get("name") for d in frappe.get_all("Domain")] add_layouts(bootinfo) bootinfo.module_app = frappe.local.module_app bootinfo.single_types = [ d.name for d in frappe.get_all('DocType', {'issingle': 1}) ] bootinfo.nested_set_doctypes = [ d.parent for d in frappe.get_all('DocField', {'fieldname': 'lft'}, ['parent']) ] add_home_page(bootinfo, doclist) bootinfo.page_info = get_allowed_pages() load_translations(bootinfo) add_timezone_info(bootinfo) load_conf_settings(bootinfo) load_print(bootinfo, doclist) doclist.extend(get_meta_bundle("Page")) bootinfo.home_folder = frappe.db.get_value("File", {"is_home_folder": 1}) bootinfo.navbar_settings = get_navbar_settings() bootinfo.notification_settings = get_notification_settings() # ipinfo if frappe.session.data.get('ipinfo'): bootinfo.ipinfo = frappe.session['data']['ipinfo'] # add docs bootinfo.docs = doclist for method in hooks.boot_session or []: frappe.get_attr(method)(bootinfo) if bootinfo.lang: bootinfo.lang = text_type(bootinfo.lang) bootinfo.versions = {k: v['version'] for k, v in get_versions().items()} bootinfo.error_report_email = frappe.conf.error_report_email bootinfo.calendars = sorted(frappe.get_hooks("calendars")) bootinfo.treeviews = frappe.get_hooks("treeviews") or [] bootinfo.lang_dict = get_lang_dict() bootinfo.success_action = get_success_action() bootinfo.update(get_email_accounts(user=frappe.session.user)) bootinfo.energy_points_enabled = is_energy_point_enabled() bootinfo.website_tracking_enabled = is_tracking_enabled() bootinfo.points = get_energy_points(frappe.session.user) bootinfo.frequently_visited_links = frequently_visited_links() bootinfo.link_preview_doctypes = get_link_preview_doctypes() bootinfo.additional_filters_config = get_additional_filters_from_hooks() bootinfo.desk_settings = get_desk_settings() bootinfo.app_logo_url = get_app_logo() return bootinfo
def load_languages(): return sorted(get_lang_dict().keys())
def get_bootinfo(): """build and return boot info""" frappe.set_user_lang(frappe.session.user) bootinfo = frappe._dict() hooks = frappe.get_hooks() doclist = [] # user get_user(bootinfo) # system info bootinfo.sitename = frappe.local.site bootinfo.sysdefaults = frappe.defaults.get_defaults() bootinfo.user_permissions = get_user_permissions() bootinfo.server_date = frappe.utils.nowdate() if frappe.session['user'] != 'Guest': bootinfo.user_info = get_fullnames() bootinfo.sid = frappe.session['sid']; bootinfo.modules = {} bootinfo.module_list = [] load_desktop_icons(bootinfo) bootinfo.letter_heads = get_letter_heads() bootinfo.active_domains = frappe.get_active_domains() bootinfo.all_domains = [d.get("name") for d in frappe.get_all("Domain")] bootinfo.module_app = frappe.local.module_app bootinfo.single_types = frappe.db.sql_list("""select name from tabDocType where issingle=1""") add_home_page(bootinfo, doclist) bootinfo.page_info = get_allowed_pages() load_translations(bootinfo) add_timezone_info(bootinfo) load_conf_settings(bootinfo) load_print(bootinfo, doclist) doclist.extend(get_meta_bundle("Page")) bootinfo.home_folder = frappe.db.get_value("File", {"is_home_folder": 1}) # ipinfo if frappe.session.data.get('ipinfo'): bootinfo.ipinfo = frappe.session['data']['ipinfo'] # add docs bootinfo.docs = doclist for method in hooks.boot_session or []: frappe.get_attr(method)(bootinfo) if bootinfo.lang: bootinfo.lang = text_type(bootinfo.lang) bootinfo.versions = {k: v['version'] for k, v in get_versions().items()} bootinfo.error_report_email = frappe.get_hooks("error_report_email") bootinfo.calendars = sorted(frappe.get_hooks("calendars")) bootinfo.treeviews = frappe.get_hooks("treeviews") or [] bootinfo.lang_dict = get_lang_dict() bootinfo.feedback_triggers = get_enabled_feedback_trigger() bootinfo.gsuite_enabled = get_gsuite_status() bootinfo.update(get_email_accounts(user=frappe.session.user)) return bootinfo
def get_languages(): from frappe.translate import get_lang_dict languages = get_lang_dict().keys() languages.sort() return [""] + languages
def get_bootinfo(): """build and return boot info""" frappe.set_user_lang(frappe.session.user) bootinfo = frappe._dict() hooks = frappe.get_hooks() doclist = [] # user get_user(bootinfo) # system info bootinfo['sysdefaults'] = frappe.defaults.get_defaults() bootinfo['server_date'] = frappe.utils.nowdate() if frappe.session['user'] != 'Guest': bootinfo['user_info'] = get_fullnames() bootinfo['sid'] = frappe.session['sid']; bootinfo.modules = {} bootinfo.module_list = [] for app in frappe.get_installed_apps(frappe_last=True): try: modules = frappe.get_attr(app + ".config.desktop.get_data")() or {} if isinstance(modules, dict): bootinfo.modules.update(modules) else: for m in modules: bootinfo.modules[m['module_name']] = m bootinfo.module_list.append(m['module_name']) except ImportError: pass except AttributeError: pass bootinfo.module_app = frappe.local.module_app bootinfo.hidden_modules = frappe.db.get_global("hidden_modules") bootinfo.doctype_icons = dict(frappe.db.sql("""select name, icon from tabDocType where ifnull(icon,'')!=''""")) bootinfo.single_types = frappe.db.sql_list("""select name from tabDocType where issingle=1""") add_home_page(bootinfo, doclist) bootinfo.page_info = get_allowed_pages() load_translations(bootinfo) add_timezone_info(bootinfo) load_conf_settings(bootinfo) load_print(bootinfo, doclist) doclist.extend(get_meta_bundle("Page")) bootinfo.home_folder = frappe.db.get_value("File", {"is_home_folder": 1}) # ipinfo if frappe.session['data'].get('ipinfo'): bootinfo['ipinfo'] = frappe.session['data']['ipinfo'] # add docs bootinfo['docs'] = doclist for method in hooks.boot_session or []: frappe.get_attr(method)(bootinfo) if bootinfo.lang: bootinfo.lang = unicode(bootinfo.lang) bootinfo['versions'] = {k: v['version'] for k, v in get_versions().items()} bootinfo.error_report_email = frappe.get_hooks("error_report_email") bootinfo.calendars = sorted(frappe.get_hooks("calendars")) bootinfo["lang_dict"] = get_lang_dict() return bootinfo