初步的 kvmd 国际化(汉化)支持

1. 添加汉化文件
2. 添加 Lanuages().gettext 函数处理字符替换
3. 修改相关字符串调用
This commit is contained in:
mofeng-git
2024-08-06 21:45:16 +08:00
parent 6a966af5fb
commit 20927c7226
34 changed files with 999 additions and 113 deletions

View File

@@ -31,6 +31,8 @@ import pygments
import pygments.lexers.data
import pygments.formatters
from gettext import translation
from .. import tools
from ..mouse import MouseRange
@@ -103,6 +105,7 @@ from ..validators.hw import valid_otg_gadget
from ..validators.hw import valid_otg_id
from ..validators.hw import valid_otg_ethernet
from ..lanuages import Lanuages
# =====
def init(
@@ -124,15 +127,16 @@ def init(
add_help=add_help,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
_ = translation(domain="message",localedir="/kvmd/i18n",languages=["zh"]).gettext
parser.add_argument("-c", "--config", default="/etc/kvmd/main.yaml", type=valid_abs_file,
help="Set config file path", metavar="<file>")
help=_("Set config file path"), metavar="<file>")
parser.add_argument("-o", "--set-options", default=[], nargs="+",
help="Override config options list (like sec/sub/opt=value)", metavar="<k=v>",)
help=_("Override config options list (like sec/sub/opt=value)"), metavar="<k=v>",)
parser.add_argument("-m", "--dump-config", action="store_true",
help="View current configuration (include all overrides)")
help=_("View current configuration (include all overrides)"))
if check_run:
parser.add_argument("--run", dest="run", action="store_true",
help="Run the service")
help=_("Run the service"))
(options, remaining) = parser.parse_known_args(argv)
if options.dump_config:
@@ -158,10 +162,7 @@ def init(
if check_run and not options.run:
raise SystemExit(
"To prevent accidental startup, you must specify the --run option to start.\n"
"Try the --help option to find out what this service does.\n"
"Make sure you understand exactly what you are doing!"
)
_("To prevent accidental startup, you must specify the --run option to start.\n")+_("Try the --help option to find out what this service does.\n")+_("Make sure you understand exactly what you are doing!"))
return (parser, remaining, config)