from yasi_applets.welcome import bp
from flask import Flask, request, session, redirect, \
     url_for, render_template, flash, Blueprint
# we use this neat little trick to get config data from the main app
from flask import current_app
import gettext

# Set up Gettext
def set_language(LANG):
    """
    Sets language for this applet
    """
    # TODO: unhardcode this path
    translations = gettext.translation("welcome", '/usr/share/yasi-daemon/yasi_applets/welcome/locales',
                                       fallback=True, languages=[LANG])
    translations.install()
    _ = translations.gettext


@bp.route('/')
def index():
    """
    The page you'd get if you access the root of
    this app in a browser.
    """
    return ("Welcome to System Installer Daemon POC <br />"
            "Version: Unavailable")


@bp.route('/main/help',methods=['GET'])
def main_welcome():
    """
    Manages the main help system.
    """
    return render_template('help.html')


@bp.route('/main/quit',methods=['GET'])
def main_quit():
    """
    Manages the quit dialog.
    """
    return render_template('quit.html')


@bp.route('/main/menu',methods=['GET'])
def main_menu():
    """
    Manages the main menu.
    """
    return render_template('menu.html')


def build_stringlist():
    """
    Return all the strings that is used in this applet.
    """
    string_dict = {}
    string_dict['main_menu'] = _("Main Menu")
    string_dict['next_text'] = _("Next")
    string_dict['nothing_yet'] = _("There is nothing yet to do here.")
    string_dict['continue'] = _("Continue")
    string_dict['previous_text'] = _("Previous")
    return string_dict

