def get_available_languages(): """Returns a list that contains all available languages. The items in the list are tuples where the first item of the tuple is the locale identifier (i.e. de_AT) and the second one the display name of the locale. For example:: [('de_AT', 'Deutsch (Österreich)')] """ return [(get_locale_identifier((l.language, l.territory)), l.display_name) for l in babel.list_translations()]
def get_available_languages(): """Returns a list that contains all available languages. The items in the list are tuples where the first item of the tuple is the locale identifier (i.e. de_AT) and the second one the display name of the locale. For example:: [('de_AT', 'Deutsch (Österreich)')] """ return [ (get_locale_identifier((l.language, l.territory)), l.display_name) for l in babel.list_translations() ]
def settings(): form = GeneralSettingsForm() form.theme.choices = [(theme.identifier, theme.name) for theme in get_themes_list()] form.language.choices = [(locale.language, locale.display_name) for locale in babel.list_translations()] if form.validate_on_submit(): current_user.theme = form.theme.data current_user.language = form.language.data current_user.save() flash(_("Settings updated."), "success") else: form.theme.data = current_user.theme form.theme.data = current_user.language return render_template("user/general_settings.html", form=form)
def settings(): form = GeneralSettingsForm() form.theme.choices = [(theme.identifier, theme.name) for theme in get_themes_list()] form.language.choices = [(locale.language, locale.display_name) for locale in babel.list_translations()] if form.validate_on_submit(): current_user.theme = form.theme.data current_user.language = form.language.data current_user.save() flash(_("Settings updated."), "success") else: form.theme.data = current_user.theme form.language.data = current_user.language return render_template("user/general_settings.html", form=form)
def available_languages(): return [(locale.language, locale.display_name) for locale in babel.list_translations()]