~metalune/simplytranslate_web

ref: 6d4e034b6d9ef47688f24629467f1d6478b60fa0 simplytranslate_web/templates/index.html -rw-r--r-- 3.0 KiB
6d4e034bmetalune Add IRC channel to README 9 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!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 }}&typingiscool={{ use_text_fields }}" method="POST">
            Translation Engine:

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

            <br>
            <br>

            <div id="fields_container">
                <div id="language_fields_container">
                    {% if use_text_fields %}

                        <input type="text" id="from_language" name="from_language" value="{{ from_l }}" placeholder="from" />
                        <input type="text" id="to_language" name="to_language" value="{{ to_l }}" placeholder="to" />

                    {% else %}
                        <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>
                    {% endif %}
                </div>

                <a href="/?typingiscool={{ not use_text_fields }}">
                    {% if use_text_fields %}
                        Use dropdowns
                    {% else %}
                        Use text fields
                    {% endif %}
                </a>

                <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>
            {# This is wrapped in a `div` so that we can center it while keeping the
            text left-aligned.
            #}
            <div><pre id="translated_text_container">{{ translation }}</pre></div>
        {% endif %}

        <br>
        <br>
        <br>

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