Some initial menu and translation work
This commit is contained in:
@@ -1,16 +1,30 @@
|
||||
from applets.software import bp
|
||||
from flask import Flask, request, session, redirect, \
|
||||
url_for, render_template, flash, Blueprint
|
||||
import gettext
|
||||
# we use this neat little trick to get config data from the main app
|
||||
from flask import current_app
|
||||
|
||||
# Set up Gettext
|
||||
def set_language(LANG):
|
||||
"""
|
||||
Sets language for this applet
|
||||
"""
|
||||
translations = gettext.translation("users", './applets/users/locales', fallback=True, languages=[LANG])
|
||||
translations.install()
|
||||
_ = translations.gettext
|
||||
|
||||
set_language('')
|
||||
|
||||
|
||||
@bp.route('/users')
|
||||
def users_root():
|
||||
"""
|
||||
Users screen for the webui.
|
||||
"""
|
||||
set_language(current_app.config['CONFIG']['settings']['language'])
|
||||
string_dict = build_stringlist()
|
||||
build_menu()
|
||||
return render_template('users.html', string_dict=string_dict)
|
||||
|
||||
|
||||
@@ -19,6 +33,7 @@ def build_stringlist():
|
||||
Return all the strings that is used in this applet.
|
||||
"""
|
||||
string_dict = {}
|
||||
string_dict['menu_item'] = _("Users")
|
||||
string_dict['initial_user_text'] = _("Let's set up an initial user.")
|
||||
string_dict['full_name'] = _("Full Name")
|
||||
string_dict['user_name'] = _("Username")
|
||||
@@ -31,3 +46,11 @@ def build_stringlist():
|
||||
string_dict['password_nomatch'] = _("These passwords do now match")
|
||||
string_dict['password_tooshort'] = _("This password is too short")
|
||||
return string_dict
|
||||
|
||||
def build_menu():
|
||||
"""
|
||||
Define menu items and paths.
|
||||
"""
|
||||
current_app.config['CONFIG']['settings']['menu']['users'] = (build_stringlist()['menu_item'], "/users", 20)
|
||||
print(current_app.config['CONFIG']['settings']['menu'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user