~metalune/simplytranslate_web

ref: ecddbe5e77349aebdcd3ba8a797114b3994d9df7 simplytranslate_web/templates/index.html -rw-r--r-- 2.1 KiB
ecddbe5e — fattalion Use select for languages and buttons for engines 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!doctype html>

{% macro lang_option(lang_name, current_lang) %}
    <option value="{{ lang_name }}" {{ 'selected' if current_lang == lang_name else '' }}>{{ lang_name }}</option>
{% endmacro %}

{% macro supported_lang_options(current_lang) %}
    {% for lang_name in supported_languages.keys() %}
        {{ lang_option(lang_name, current_lang) }}
    {% endfor %}
{% endmacro %}

<html>
    <head>
        <title>SWT - Simple Web Translator</title>
        <link rel="stylesheet" href="/static/home.css">
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    </head>

    <body>
        <h1>Simple Web Translator</h1>

        <form action="/?engine={{ engine }}" method="POST">
            Translation Engine:

            <button type="submit" formaction="/?engine=google&switchengine=true" formmethod="POST">Google</button>
            <button type="submit" formaction="/?engine=libre&switchengine=true" formmethod="POST">LibreTranslate</button>

            <br>
            <br>

            <div id="fields_container">
                <div id="language_fields_container">
                    <select name="from_language" id="from_language">
                        {{ lang_option('Autodetect', from_l) }}
                        {{ supported_lang_options(from_l) }}
                    </select>

                    <select name="to_language" id="to_language">
                        {{ supported_lang_options(to_l) }}
                    </select>
                </div>

                <br>

                <textarea id="input" name="input" rows="5" placeholder="text you want to translate">{{ inp }}</textarea>
            </div>

            <br>

	    <button type="submit">Translate with {{ engine }}!</button>
        </form>

        <br>

        {% if translation %}
            <b>Translation ({{ engine }}):</b><br>
            {{ translation }}
        {% endif %}

        <br>
        <br>
        <br>

        <footer>
              <a href="https://git.sr.ht/~metalune/simplytranslate_web">Source for this Website</a>
        </footer>
    </body>
</html>