diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index fedd2be..dd0f06e 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -17,6 +17,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install pylint pip install -r requirements.txt - name: Analysing the code with pylint run: | diff --git a/app.py b/app.py index b9b9c4f..a163ef6 100644 --- a/app.py +++ b/app.py @@ -7,12 +7,15 @@ from flask import Flask, render_template, request, send_from_directory from flask_wtf import FlaskForm from wtforms import StringField, SubmitField +from flask_babel import Babel, gettext from base import data, is_valid_key, get_translation flask_app = Flask(__name__) flask_app.config["SECRET_KEY"] = getenv("SECRET_KEY", "dev") +babel = Babel(flask_app) + page_lang = { "zh_cn": { "lang_name": "简体中文(中国大陆)", @@ -32,8 +35,8 @@ class QueryForm(FlaskForm): """查询表单""" - source_string = StringField("查询的源字符串内容:") - submit = SubmitField("查询") + source_string = StringField(gettext("query_input_label")) + submit = SubmitField(gettext("query_button")) @flask_app.route("/", methods=["GET", "POST"]) diff --git a/static/style.css b/static/style.css index 43c8af0..04309e9 100644 --- a/static/style.css +++ b/static/style.css @@ -103,6 +103,27 @@ body { height: auto; } +/* 语言选单样式 */ + +.page-lang-selector { + position: fixed; + top: 10px; + left: 10px; + display: flex; + align-items: center; +} + +.page-lang-selector label{ + text-align: right; +} + +.page-lang-selector select { + padding-top: .25em; + padding-bottom: .25em; + border: 1px solid #ccc; + border-radius: 5px; +} + /* 标题样式 */ .title { font-family: 'Noto Serif CJK SC SemiBold', 'Source Han Serif SC SemiBold', '思源宋体 SemiBold', SimSun, 'Times New Roman', Times, serif;