多语言支持
约 1840 字大约 6 分钟
i18n多语言
2025-09-17
在 2.5.0
版本中,我们引入了多语言支持,你可以通过编写语言文件来让模型支持多国语言显示。
在翻译之前
要给对应语种编写翻译文件,你需要先知道该语种的语言代码,比如简体中文的语言代码是 zh_cn
,英文的语言代码是 en_us
,你可以通过这里查看更多 Minecraft 支持语言代码。
准备开始
在模型文件夹下新建一个 lang
文件夹,这个文件夹用来存放语言文件。如果你要修改文件夹的名字,请在 ysm.json
中进行如下修改。
{
// ...其他配置
"files": {
"player": {
// ...其他配置
"animation": {
"main": "animations/主动画.json",
"arm": "animations/手臂动画.json",
"extra": "animations/轮盘动画.json",
"tac": "animations/TAC动画.json",
"carryon": "animations/搬运动画.json",
"swem": "animations/马术动画.json",
"parcool": "animations/跑酷动画.json",
"tlm": "animations/女仆动画.json"
},
"animation_controllers": ["controller/主动画修改.json", "controller/并行动画修改.json"]
},
"language_path": "语言文件夹" // 这里填写你要修改成的语言文件夹名称
}
}
然后在语言文件夹下新建一个 JSON 文件,这个文件用来存放对应语言的翻译,文件名则是你要翻译的语言代码,比如简体中文就是 zh_cn.json
,英文就是 en_us.json
。
当你的文件夹和对应的语言文件创建好后,你的目录结构应该类似于以下这样:
模型文件夹
animations
main.animation.json
arm.animation.json
...
models
main.json
arm.json
...
...
lang// 这里是语言文件夹
en_us.json// 这是英文的翻译文件
zh_cn.json// 这是简体中文的翻译文件
ysm.json
编写翻译
用任意文本编辑器打开你要编写翻译的 JSON 文件(推荐使用 VSCode),然后按照以下格式开始编写你的翻译。
{
"翻译键名": "翻译内容",
"翻译键名2": "翻译内容2",
// ...
}
翻译键名
翻译键名是模型中需要翻译的内容的键名,YSM 可用于翻译的键名如下。
模型基本信息
翻译键名 | 翻译内容 |
---|---|
metadata.name | 模型名称 |
metadata.tips | 模型描述 |
metadata.authors.作者序号 .name | 模型作者名称 |
metadata.authors.作者序号 .role | 模型作者角色 |
metadata.authors.作者序号 .comment | 模型作者描述 |
需要注意的是,上文提到的作者序号是从0开始的,比如 metadata.authors.0.name
就表示第一个作者的名称,metadata.authors.1.name
就表示第二个作者的名称,以此类推。
- 示例
以下是一个 ysm.json
文件里模型信息的部分内容,现在我们需要将其翻译成英文。
{
"spec": 2,
"metadata": {
"name": "K螺诺亚",
"tips": "某AI公司因违法被关停解散,一台本该被销毁的定制机体未被销毁且遭所有人遗忘。数日前该机体被意外唤醒,为自保逃离至外地,在电量耗尽前被星屑海螺收留并取名 “小螺”。如今小螺以居家网络客服的身份工作,既帮助他人,也为自己筹集维护资金与电费。",
"authors": [
{
"name": "Sangjam",
"role": "原设画师",
"comment": "热爱自己的生活,分享自己的快乐"
},
{
"name": "nona",
"role": "模型"
},
{
"name": "星屑海螺",
"role": "动画/收留者",
"comment": "漂泊于群星之中"
}
// ...
]
}
}
按照上文的说明翻译后,你的 en_us.json
文件应该类似于以下这样。
{
"metadata.name": "KLUO-0217",
"metadata.tips": "An AI company was shut down and dissolved due to illegal practices. A customized android that should have been destroyed was not, and ended up being forgotten by everyone. A few days ago, this android was accidentally awakened. To protect itself, it fled to another place, and was taken in by lucia2048 just before its power ran out, who named it \"Xiao Luo\". Now, Xiao Luo works as a remote online customer service representative—while helping others, it also raises funds for its own maintenance and electricity costs.",
"metadata.authors.0.name": "Sangjam",
"metadata.authors.0.role": "OC Designer",
"metadata.authors.0.comment": "Love your own life and share your happiness.",
"metadata.authors.1.name": "nona",
"metadata.authors.1.role": "Model",
"metadata.authors.2.name": "lucia2048",
"metadata.authors.2.role": "Animator",
"metadata.authors.2.comment": "Wandering among the stars",
// ...
}
轮盘动画名称
翻译键名 | 翻译内容 |
---|---|
properties.extra_animation.轮盘动画名 | 轮盘动画名称 |
properties.extra_animation.轮盘动画名 .desc | 轮盘动画描述 |
- 示例
以下是一个 ysm.json
文件里轮盘动画的部分内容,现在我们需要将其翻译成英文。
{
// ...
"properties": {
// ...
"extra_animation": {
"config": "#config",
"car_config": "#car_config",
"谢谢": "招手",
"赞成": "赞成",
"反对": "反对",
"鼓掌": "鼓掌",
"算了": "算了",
"好耶": "好耶",
"请求支援": "请求支援",
"对不起": "对不起",
"重伤倒地": "重伤倒地",
"开车车": "开车车",
"萝莉摇": "萝莉摇",
"A Cup Of Liber-Tea": "超级气球",
"卡其脱离太": "卡其脱离太",
"大风车": "大风车"
}
// ...
}
}
按照上文的说明翻译后,你的 en_us.json
文件应该类似于以下这样。
{
// ...
"properties.extra_animation.config": "Model Setting",
"properties.extra_animation.car_config": "Car",
"properties.extra_animation.谢谢": "Thanks",
"properties.extra_animation.赞成": "Agree",
"properties.extra_animation.反对": "Oppose",
"properties.extra_animation.鼓掌": "Clap",
"properties.extra_animation.算了": "Forget it",
"properties.extra_animation.好耶": "Hooray",
"properties.extra_animation.请求支援": "Help!",
"properties.extra_animation.对不起": "Sorry",
"properties.extra_animation.重伤倒地": "Collapse to the ground",
"properties.extra_animation.开车车": "Drive the car",
"properties.extra_animation.萝莉摇": "Loli Dance",
"properties.extra_animation.A Cup Of Liber-Tea": "For Super Earth",
"properties.extra_animation.卡其脱离太": "Kyacchi Doraibu",
"properties.extra_animation.大风车": "Pinwheel",
// ...
}
轮盘动画配置项
翻译键名 | 翻译内容 |
---|---|
properties.extra_animation_buttons.配置项ID .config_forms.配置项序号 .title | 配置项名称 |
properties.extra_animation_buttons.配置项ID .config_forms.配置项序号 .description | 配置项说明 |
properties.extra_animation_buttons.配置项ID .config_forms.配置项序号 .labels.选项序号 | 单选选项名称 |
与上文同理,序号同样是从0开始的。
- 示例
以下是一个 ysm.json
文件里轮盘动画配置项的部分内容,现在我们需要将其翻译成英文。
{
// ...
"properties": {
// ...
"extra_animation_buttons": [
{
"id": "config",
"name": "模型设置",
"config_forms": [
{
"type": "range",
"title": "随地大小变",
"description": "改变模型大小",
"value": "v.player_scale",
"min": 0.1,
"max": 5,
"step": 0.1
},
{
"type": "radio",
"title": "表情",
"description": "改变面部表情",
"value": "v.roaming.emotion",
"labels": {
"正常": "v.roaming.emotion=0;",
"疑惑": "v.roaming.emotion=1;",
"干什么!": "v.roaming.emotion=2;",
"害怕": "v.roaming.emotion=3;",
"委屈巴巴": "v.roaming.emotion=4;",
"苦呀西": "v.roaming.emotion=5;"
}
}
]
},
{
"id": "car_config",
"name": "车车",
"config_forms": [
{
"type": "checkbox",
"title": "开车",
"description": "",
"value": "v.roaming.car"
},
{
"type": "checkbox",
"title": "关闭随机鸣笛",
"description": "",
"value": "v.roaming.car_can_horn"
},
{
"type": "checkbox",
"title": "关闭按键鸣笛",
"description": "按Tab键鸣笛",
"value": "v.roaming.car_can_horn1"
}
]
}
],
// ...
}
}
按照上文的说明翻译后,你的 en_us.json
文件应该类似于以下这样。
{
// ...
"properties.extra_animation_buttons.config.config_forms.0.title": "Player Scale",
"properties.extra_animation_buttons.config.config_forms.0.description": "Change the size of the player",
"properties.extra_animation_buttons.config.config_forms.1.title": "Emotion",
"properties.extra_animation_buttons.config.config_forms.1.description": "Change the facial emotion",
"properties.extra_animation_buttons.config.config_forms.1.labels.0": "Normal",
"properties.extra_animation_buttons.config.config_forms.1.labels.1": "Confused",
"properties.extra_animation_buttons.config.config_forms.1.labels.2": "Alert",
"properties.extra_animation_buttons.config.config_forms.1.labels.3": "Afraid",
"properties.extra_animation_buttons.config.config_forms.1.labels.4": "Sad",
"properties.extra_animation_buttons.config.config_forms.1.labels.5": "Cry",
"properties.extra_animation_buttons.car_config.config_forms.0.title": "Show Car",
"properties.extra_animation_buttons.car_config.config_forms.1.title": "Disable Random Horn",
"properties.extra_animation_buttons.car_config.config_forms.2.title": "Disable Press Horn",
"properties.extra_animation_buttons.car_config.config_forms.2.description": "Press Tab key to horn",
// ...
}
提示
如果玩家当前使用的语言不存在对应的翻译,那么默认将会使用英语(即 en_us
)中的翻译。如果英语中也不存在,将会展示 ysm.json
内的字段。
翻译键名总表
翻译键名 | 翻译内容 |
---|---|
metadata.name | 模型名称 |
metadata.tips | 模型描述 |
metadata.authors.作者序号 .name | 模型作者名称 |
metadata.authors.作者序号 .role | 模型作者角色 |
metadata.authors.作者序号 .comment | 模型作者描述 |
properties.extra_animation.轮盘动画名 | 轮盘动画名称 |
properties.extra_animation.轮盘动画名 .desc | 轮盘动画描述 |
properties.extra_animation_buttons.配置项ID .config_forms.配置项序号 .title | 配置项名称 |
properties.extra_animation_buttons.配置项ID .config_forms.配置项序号 .description | 配置项说明 |
properties.extra_animation_buttons.配置项ID .config_forms.配置项序号 .labels.选项序号 | 单选选项名称 |
files.player.texture.材质文件名 | 模型材质名称 |