Exemplo n.º 1
0
def get_translated_dict():
    from babel.dates import Locale, get_timezone, get_timezone_name

    translated_dict = {}
    locale = Locale.parse(frappe.local.lang, sep="-")

    # timezones
    for tz in get_all_timezones():
        timezone_name = get_timezone_name(get_timezone(tz),
                                          locale=locale,
                                          width="short")
        if timezone_name:
            translated_dict[tz] = timezone_name + " - " + tz

    # country names && currencies
    for country, info in get_all().items():
        country_name = locale.territories.get((info.get("code") or "").upper())
        if country_name:
            translated_dict[country] = country_name

        currency = info.get("currency")
        currency_name = locale.currencies.get(currency)
        if currency_name:
            translated_dict[currency] = currency_name

    return translated_dict
Exemplo n.º 2
0
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)

    return {"timezones": get_all_timezones(), "defaults": defaults}
Exemplo n.º 3
0
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)

	return {
		"timezones": get_all_timezones(),
		"defaults": defaults
	}
Exemplo n.º 4
0
def get_timezones():
    from babel.dates import get_timezone, get_timezone_name, Locale
    from frappe.utils.momentjs import get_all_timezones

    translated_dict = {}
    locale = Locale.parse(frappe.local.lang, sep="-")

    for tz in get_all_timezones():
        timezone_name = get_timezone_name(get_timezone(tz),
                                          locale=locale,
                                          width='short')
        if timezone_name:
            translated_dict[tz] = timezone_name + ' - ' + tz

    return translated_dict
Exemplo n.º 5
0
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()
    #hotfix, only open languages when needed
    return {
        "timezones": get_all_timezones(),
        #"languages": [""] + languages,
        "languages": ["english", u"中国(简体)"],
        "defaults": defaults
    }
Exemplo n.º 6
0
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()
	#hotfix, only open languages when needed
	return {
		"timezones": get_all_timezones(),
		#"languages": [""] + languages,
		"languages": ["english",u"中国(简体)"],
		"defaults": defaults
	}
Exemplo n.º 7
0
def get_translated_dict():
	from babel.dates import get_timezone, get_timezone_name, Locale

	translated_dict = {}
	locale = Locale.parse(frappe.local.lang, sep="-")

	# timezones
	for tz in get_all_timezones():
		timezone_name = get_timezone_name(get_timezone(tz), locale=locale, width='short')
		if timezone_name:
			translated_dict[tz] = timezone_name + ' - ' + tz

	# country names && currencies
	for country, info in get_all().items():
		country_name = locale.territories.get((info.get("code") or "").upper())
		if country_name:
			translated_dict[country] = country_name

		currency = info.get("currency")
		currency_name = locale.currencies.get(currency)
		if currency_name:
			translated_dict[currency] = currency_name

	return translated_dict
Exemplo n.º 8
0
def get_country_timezone_info():
	return {
		"country_info": get_all(),
		"all_timezones": get_all_timezones()
	}
Exemplo n.º 9
0
def get_country_timezone_info():
    return {"country_info": get_all(), "all_timezones": get_all_timezones()}