Skip to content

Commit

Permalink
Update translations
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyEye-FAST committed Jan 27, 2024
1 parent 4863b96 commit 9c85506
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 20 deletions.
21 changes: 13 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField

from flask_babel import Babel, lazy_gettext, format_date
from flask_babel import Babel, format_date
from flask_babel import lazy_gettext as _l
from babel.dates import get_timezone_name
import geoip2.database
import geoip2.errors
Expand All @@ -29,9 +30,10 @@ def get_locale():

babel = Babel(flask_app, locale_selector=get_locale)


@flask_app.before_request
def determine_timezone():
"""根据IP获取时间"""
"""根据IP获取时区"""
ip = request.remote_addr
try:
with geoip2.database.Reader(P / "GeoLite2-City.mmdb") as reader:
Expand All @@ -45,18 +47,21 @@ def determine_timezone():
class QueryForm(FlaskForm):
"""查询表单"""

source_string = StringField(lazy_gettext("Source string content to be queried: "))
submit = SubmitField(lazy_gettext("QUERY"))
source_string = StringField(_l("Source string content to be queried: "))
submit = SubmitField(_l("QUERY"))


@flask_app.route("/", methods=["GET", "POST"])
def index():
"""主页面"""
if 'timezone' in session:
timezone = session['timezone']
timezone_str = get_timezone_name(timezone, locale=get_locale())

# 时区
if "timezone" in session:
timezone = session["timezone"]
else:
timezone_str = "UTC"
timezone = request.headers.get("Time-Zone")
timezone_str = get_timezone_name(timezone, locale=get_locale())

form = QueryForm()

query_str = form.source_string.data
Expand Down
20 changes: 16 additions & 4 deletions messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-01-27 20:32+0800\n"
"POT-Creation-Date: 2024-01-27 23:25+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -17,15 +17,27 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.14.0\n"

#: app.py:22
msgid "Source string content to be queried:"
#: app.py:49
msgid "Source string content to be queried: "
msgstr ""

#: app.py:23
#: app.py:50
msgid "QUERY"
msgstr ""

#: templates/index.html:23
msgid "Select translation key:"
msgstr ""

#: templates/index.html:47
msgid "Language Names"
msgstr ""

#: templates/index.html:48
msgid "Translations"
msgstr ""

#: templates/index.html:70
msgid "Minecraft Chinese Standard Translations"
msgstr ""

6 changes: 3 additions & 3 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
</div>
<table>
<tr>
<th class="table-header">语言名称</th>
<th class="table-header">译名</th>
<th class="table-header">{{ _("Language Names") }}</th>
<th class="table-header">{{ _("Translations") }}</th>
</tr>
<tr lang="zh-Hans-CN" class="zh-cn">
<td class="lang-name">简体中文&#10;(中国大陆)</td>
Expand All @@ -67,7 +67,7 @@
{% endif %}

<div class="minecraft-title">
Minecraft中文标准译名<br>
{{ _("Minecraft Chinese Standard Translations") }}<br>
<span style="font-size: smaller;">
<time datetime="{{ date_str }}">{{ date_str_t }}</time> - {{ timezone_str }}
</span>
Expand Down
Binary file modified translations/zh_CN/LC_MESSAGES/messages.mo
Binary file not shown.
22 changes: 17 additions & 5 deletions translations/zh_CN/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Minecraft Chinese Standard Translations\n"
"Project-Id-Version: Demo\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-01-27 20:32+0800\n"
"PO-Revision-Date: 2024-01-27 20:32+0800\n"
"POT-Creation-Date: 2024-01-27 23:25+0800\n"
"PO-Revision-Date: 2024-01-27 23:25+0800\n"
"Last-Translator: SkyEye_FAST <[email protected]>\n"
"Language: zh_Hans_CN\n"
"Language-Team: zh_Hans_CN <[email protected]>\n"
Expand All @@ -18,15 +18,27 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.14.0\n"

#: app.py:22
#: app.py:49
msgid "Source string content to be queried: "
msgstr "查询的源字符串内容:"

#: app.py:23
#: app.py:50
msgid "QUERY"
msgstr "查询"

#: templates/index.html:23
msgid "Select translation key:"
msgstr "选择本地化键名:"

#: templates/index.html:47
msgid "Language Names"
msgstr "语言名称"

#: templates/index.html:48
msgid "Translations"
msgstr "译名"

#: templates/index.html:70
msgid "Minecraft Chinese Standard Translations"
msgstr "Minecraft中文标准译名"

44 changes: 44 additions & 0 deletions translations/zh_TW/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Chinese (Traditional, Taiwan) translations for Minecraft Chinese Standard Translations.
# Copyright (C) 2024 SkyEye_FAST
# This file is distributed under the same license as the Minecraft Chinese Standard Translations project.
# SkyEye_FAST <[email protected]>, 2024.
#
msgid ""
msgstr ""
"Project-Id-Version: Demo\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-01-27 23:25+0800\n"
"PO-Revision-Date: 2024-01-27 23:27+0800\n"
"Last-Translator: SkyEye_FAST <[email protected]>\n"
"Language: zh_Hant_TW\n"
"Language-Team: zh_Hant_TW <[email protected]>\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.14.0\n"

#: app.py:49
msgid "Source string content to be queried: "
msgstr "需要查詢的來源字串內容:"

#: app.py:50
msgid "QUERY"
msgstr "查詢"

#: templates/index.html:23
msgid "Select translation key:"
msgstr "選擇本地化鍵名:"

#: templates/index.html:47
msgid "Language Names"
msgstr "語言名稱"

#: templates/index.html:48
msgid "翻譯"
msgstr ""

#: templates/index.html:70
msgid "Minecraft Chinese Standard Translations"
msgstr "Minecraft 中文標準翻譯"

0 comments on commit 9c85506

Please sign in to comment.