def index(): """ Welcome page in HTML. """ muas = [ {'option':'macmail','name': 'Apple OSX Mail'}, {'option':'outlook','name': 'Microsoft Outlook'}, {'option':'gmailweb','name': 'Gmail Web'}, {'option':'gmailandroid','name': 'Gmail Android'}, ] template_doc = "doc/empty.html" locale = ptrans.best_locale() email = request.args.get('emailaddress') context['bootswatch'] = conf.get('general', 'bootswatch') mua = request.args.get('mua') selected_mua = None context['email'] = '' try: locale = request.headers.get('Accept-Language').split(",")[0] except: pass if email and '.' in email and '@' in email and mua: mailbox, domain = email.split('@') context['domain'] = domain context['email'] = email selected_mua = mua template_doc = "doc/%s-%s.md" % (mua, locale) context['selected_mua'] = selected_mua context['template_doc'] = template_doc context['locale'] = locale context['muas'] = muas return render_template('hello.html', **context)
def index_page(): locale = request.args.get('locale') if not locale: locale = ptrans.best_locale() global RENDER_COUNTER RENDER_COUNTER += 1 return render_template('index.html', locale=locale, render_count=RENDER_COUNTER)
def test_best_locale_no_request(): """ best_locale returns en-GB if flask has no request context or if no locales are known """ assert ptrans.best_locale() == "en-GB"
def test_best_locale_no_request(): """ best_locale returns en-GB if flask has no request context or if no locales are known """ assert_equals(ptrans.best_locale(), "en-GB")