🌐 支持i18n (#501)

*  支持 i18n #410

* 🚨 更改noqa方式

* 📝 添加 CONTRIBUTING.md 文件

* 🌐 将 i18n 默认语言设置为 en-US

* 📝 添加英文版 CONTRIBUTING.md
This commit is contained in:
呵呵です
2024-10-26 18:29:51 +08:00
committed by GitHub
parent a0fd9eaed3
commit b2d5a1e729
17 changed files with 374 additions and 15 deletions

View File

@@ -0,0 +1,5 @@
{
"default": "en-US",
"frozen": [],
"require": []
}

View 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"
}
}
}
}
}
}
}

View 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"] }]
}
]
}

View 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"
}
}
}
}
]
}
}
}
}
}
}
}

View 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

View 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"
}
}
}

View 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

View File

@@ -0,0 +1,14 @@
{
"$schema": ".lang.schema.json",
"interaction": {
"wrong": { "query_bot": "不能查询bot的信息" },
"warning": { "unverified": "* 由于无法验证绑定信息, 不能保证查询到的用户为本人" }
},
"error": {
"MessageFormatError": {
"TETR.IO": "用户名/ID不合法",
"TOS": "用户名/ID不合法",
"TOP": "用户名不合法"
}
}
}