mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
🌐 支持i18n (#501)
* ✨ 支持 i18n #410 * 🚨 更改noqa方式 * 📝 添加 CONTRIBUTING.md 文件 * 🌐 将 i18n 默认语言设置为 en-US * 📝 添加英文版 CONTRIBUTING.md
This commit is contained in:
5
nonebot_plugin_tetris_stats/i18n/.config.json
Normal file
5
nonebot_plugin_tetris_stats/i18n/.config.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"default": "en-US",
|
||||
"frozen": [],
|
||||
"require": []
|
||||
}
|
||||
72
nonebot_plugin_tetris_stats/i18n/.lang.schema.json
Normal file
72
nonebot_plugin_tetris_stats/i18n/.lang.schema.json
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"title": "Lang Schema",
|
||||
"description": "Schema for lang file",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"interaction": {
|
||||
"title": "Interaction",
|
||||
"description": "Scope 'interaction' of lang item",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"wrong": {
|
||||
"title": "Wrong",
|
||||
"description": "Scope 'wrong' of lang item",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"query_bot": {
|
||||
"title": "query_bot",
|
||||
"description": "value of lang item type 'query_bot'",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"warning": {
|
||||
"title": "Warning",
|
||||
"description": "Scope 'warning' of lang item",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"unverified": {
|
||||
"title": "unverified",
|
||||
"description": "value of lang item type 'unverified'",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"title": "Error",
|
||||
"description": "Scope 'error' of lang item",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"MessageFormatError": {
|
||||
"title": "Messageformaterror",
|
||||
"description": "Scope 'MessageFormatError' of lang item",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"TETR.IO": {
|
||||
"title": "TETR.IO",
|
||||
"description": "value of lang item type 'TETR.IO'",
|
||||
"type": "string"
|
||||
},
|
||||
"TOS": {
|
||||
"title": "TOS",
|
||||
"description": "value of lang item type 'TOS'",
|
||||
"type": "string"
|
||||
},
|
||||
"TOP": {
|
||||
"title": "TOP",
|
||||
"description": "value of lang item type 'TOP'",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
16
nonebot_plugin_tetris_stats/i18n/.template.json
Normal file
16
nonebot_plugin_tetris_stats/i18n/.template.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"$schema": ".template.schema.json",
|
||||
"scopes": [
|
||||
{
|
||||
"scope": "interaction",
|
||||
"types": [
|
||||
{ "subtype": "wrong", "types": ["query_bot"] },
|
||||
{ "subtype": "warning", "types": ["unverified"] }
|
||||
]
|
||||
},
|
||||
{
|
||||
"scope": "error",
|
||||
"types": [{ "subtype": "MessageFormatError", "types": ["TETR.IO", "TOS", "TOP"] }]
|
||||
}
|
||||
]
|
||||
}
|
||||
54
nonebot_plugin_tetris_stats/i18n/.template.schema.json
Normal file
54
nonebot_plugin_tetris_stats/i18n/.template.schema.json
Normal file
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"title": "Template",
|
||||
"description": "Template for lang items to generate schema for lang files",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"scopes": {
|
||||
"title": "Scopes",
|
||||
"description": "All scopes of lang items",
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"title": "Scope",
|
||||
"description": "First level of all lang items",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"scope": {
|
||||
"type": "string",
|
||||
"description": "Scope name"
|
||||
},
|
||||
"types": {
|
||||
"type": "array",
|
||||
"description": "All types of lang items",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Value of lang item"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"subtype": {
|
||||
"type": "string",
|
||||
"description": "Subtype name of lang item"
|
||||
},
|
||||
"types": {
|
||||
"type": "array",
|
||||
"description": "All subtypes of lang items",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"$ref": "#/properties/scopes/items/properties/types/items"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
nonebot_plugin_tetris_stats/i18n/__init__.py
Normal file
12
nonebot_plugin_tetris_stats/i18n/__init__.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# This file is @generated by tarina.lang CLI tool
|
||||
# It is not intended for manual editing.
|
||||
|
||||
# ruff: noqa: E402, F401, PLC0414
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from tarina.lang import lang # type: ignore[import-untyped]
|
||||
|
||||
lang.load(Path(__file__).parent)
|
||||
|
||||
from .model import Lang as Lang
|
||||
16
nonebot_plugin_tetris_stats/i18n/en-US.json
Normal file
16
nonebot_plugin_tetris_stats/i18n/en-US.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"$schema": ".lang.schema.json",
|
||||
"interaction": {
|
||||
"wrong": { "query_bot": "Can't query bot's information" },
|
||||
"warning": {
|
||||
"unverified": "* Because I can't verify account linking information, I can't guarantee the info I found is yourself/themself."
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"MessageFormatError": {
|
||||
"TETR.IO": "Username/ID is invalid",
|
||||
"TOS": "Username/ID is invalid",
|
||||
"TOP": "Username is invalid"
|
||||
}
|
||||
}
|
||||
}
|
||||
32
nonebot_plugin_tetris_stats/i18n/model.py
Normal file
32
nonebot_plugin_tetris_stats/i18n/model.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# This file is @generated by tarina.lang CLI tool
|
||||
# It is not intended for manual editing.
|
||||
|
||||
from tarina.lang.model import LangItem, LangModel # type: ignore[import-untyped]
|
||||
|
||||
|
||||
class InteractionWrong:
|
||||
query_bot: LangItem = LangItem('interaction', 'wrong.query_bot')
|
||||
|
||||
|
||||
class InteractionWarning:
|
||||
unverified: LangItem = LangItem('interaction', 'warning.unverified')
|
||||
|
||||
|
||||
class Interaction:
|
||||
wrong = InteractionWrong
|
||||
warning = InteractionWarning
|
||||
|
||||
|
||||
class ErrorMessageformaterror:
|
||||
TETR_IO: LangItem = LangItem('error', 'MessageFormatError.TETR.IO')
|
||||
TOS: LangItem = LangItem('error', 'MessageFormatError.TOS')
|
||||
TOP: LangItem = LangItem('error', 'MessageFormatError.TOP')
|
||||
|
||||
|
||||
class Error:
|
||||
MessageFormatError = ErrorMessageformaterror
|
||||
|
||||
|
||||
class Lang(LangModel):
|
||||
interaction = Interaction
|
||||
error = Error
|
||||
14
nonebot_plugin_tetris_stats/i18n/zh-CN.json
Normal file
14
nonebot_plugin_tetris_stats/i18n/zh-CN.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"$schema": ".lang.schema.json",
|
||||
"interaction": {
|
||||
"wrong": { "query_bot": "不能查询bot的信息" },
|
||||
"warning": { "unverified": "* 由于无法验证绑定信息, 不能保证查询到的用户为本人" }
|
||||
},
|
||||
"error": {
|
||||
"MessageFormatError": {
|
||||
"TETR.IO": "用户名/ID不合法",
|
||||
"TOS": "用户名/ID不合法",
|
||||
"TOP": "用户名不合法"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user