コード例 #1
0
ファイル: country_info.py プロジェクト: erpnext-tm/frappe
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
コード例 #2
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
コード例 #3
0
ファイル: country_info.py プロジェクト: AhmedHamedTN/frappe
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