完整版BedrockWiki镜像!

This commit is contained in:
boybook
2025-03-20 11:52:46 +08:00
parent 1994c41f01
commit bf9aa4b056
214 changed files with 9042 additions and 8867 deletions

View File

@@ -1,5 +1,5 @@
---
title: Text and Localization
title: 文本与本地化
mentions:
- ThijsHankelMC
- SirLich
@@ -14,13 +14,17 @@ mentions:
- Sprunkles
---
Minecraft is a game with fully localized text in languages all over the world. To achieve this, Minecraft employs a system where internal **translation keys** are assigned values on a per-language basis. Minecraft will generate translation keys for custom entities, items, and blocks, and it is up to us to assign them a localized name in our resource pack.
# 文本与本地化
## Language Files
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
### File Location
Minecraft 是一款支持全球多语言本地化的游戏。为实现这一特性,游戏采用了基于语言代码的**翻译键值系统**。对于自定义实体Entity、物品Item和方块BlockMinecraft 会自动生成翻译键值,而我们需要通过资源包为其提供本地化文本。
Language files typically go within the resource pack in the "texts" folder as files with the `.lang` file extension. These files can be placed in the behavior pack, but the only translatable text it can change is the pack manifest's name and description.
## 语言文件
### 文件位置
语言文件通常位于资源包的 `texts` 文件夹中,使用 `.lang` 扩展名。虽然也可以放置在行为包中但行为包仅能修改资源包清单manifest的名称和描述。
<FolderView :paths="[
'RP/texts/en_US.lang',
@@ -29,128 +33,128 @@ Language files typically go within the resource pack in the "texts" folder as fi
]"
></FolderView>
Minecraft supports 29 languages currently, as described in [§ Vanilla Languages](/concepts/text-and-translations#vanilla-languages).
Minecraft 目前支持 29 种语言,详见 [§ 原版支持语言](/wiki/concepts/text-and-translations#vanilla-languages)
### Format
### 格式规范
The format for a language file is rather straightforward. Translations are supplied as key-value pairs separated by an equals sign (`=`), the key being a translation key and the value being a string. Values cannot contain newline characters.
语言文件采用键值对格式,使用等号(`=`)分隔。键为翻译键值,值为字符串(不支持换行符)。
```toml
wiki.example_translation.line_1=The first line!
wiki.example_translation.line_2=Some more information following the first line.
wiki.example_translation.line_1=第一行内容!
wiki.example_translation.line_2=这里是第一行之后的其他信息。
```
Comments may be added with two pound signs (`##`), either as line comments or in-line comments. All text after the pound signs are a comment until the next line.
可通过双井号(`##`)添加注释,支持行尾注释和整行注释(注释内容持续到行尾)。
:::warning
Trailing spaces are not trimmed for in-line comments. If you want to indent a comment, use the Tab character.
行尾注释前的空格不会被自动删除。如需缩进注释请使用制表符Tab
:::
```toml
## Translator note: I thought this would be funny to put here.
item.flint_and_steel.name=Flint and Steve ##[sic]
## 译者注:这个翻译可能有点幽默成分
item.flint_and_steel.name=燧石与史蒂夫 ##[原文如此]
```
A translation can contain substitutions in place of text. Substitutions can either be ordered (`%1`, `%2`, etc.) or not ordered (`%s`). Vanilla translations have their values filled in by the game, while players can manually set the substitutions' values with commands that use the raw JSON text format, like with [`/tellraw`](/commands/tellraw).
翻译文本支持占位符替换,可使用有序占位符(`%1``%2`)或无序占位符(`%s`。原版占位符由游戏自动填充而通过原始JSON文本命令 [`/tellraw`](/wiki/commands/tellraw))可手动指定替换值。
```toml
commands.op.success=Opped: %s
immersive_reader.book_page_header=Page %1 of %2
commands.op.success=已授予管理员权限:%s
immersive_reader.book_page_header= %1 / %2
```
### Usage
### 应用场景
Localization can be done just about anywhere text can be used, including (but not limited to):
本地化文本可用于以下场景(包括但不限于):
- Pack name and description
- Entity, item, or block names
- Pages in a book
- Lines on a sign
- `/tellraw` and `/titleraw` commands
- Text in dialogue
- 资源包/行为包名称与描述
- 实体、物品或方块的名称
- 书页内容
- 告示牌文字
- `/tellraw` `/titleraw` 命令
- 对话系统中的文本
Some text cannot be translated however, such as for an item renamed in an anvil.
但某些文本(如铁砧重命名的物品)不支持本地化。
## Localization
## 本地化实践
:::tip
It is good practice create a copy of your language file for each major language your pack supports. For example, to support full English one should create both an `en_US.lang` and an `en_GB.lang` file, to cover English in both the United States and Great Britain countries, respectively.
最佳实践是为每个主要支持语言创建独立语言文件。例如要完整支持英语,应同时创建 `en_US.lang`(美式英语)和 `en_GB.lang`(英式英语)文件。
:::
When editing language files one must also add a `languages.json` file in the `texts` folder containing an array with each of the languages you plan to change. This lets Minecraft know that it should apply localization for these languages.
编辑语言文件时,需在 `texts` 文件夹中添加 `languages.json` 文件,声明需要修改的语言列表。这会告知 Minecraft 应用对应的本地化配置。
<CodeHeader>RP/texts/languages.json</CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
[
"en_US",
"en_GB",
"fr_FR"
]
```
:::
### Custom Languages
### 自定义语言
With a global resource pack, custom languages may be introduced through the `languages.json` and `language_names.json` files. Once the pack is applied globally the language can be changed in the "Language" tab of the in-game settings.
通过全局资源包,可使用 `languages.json` 和 `language_names.json` 添加自定义语言。应用全局资源包后,即可在游戏设置的"语言"选项中选择新语言。
For the following examples, lets assume that we have 2 fully functional language files, one named `xx_XX.lang`, and another named `yy_YY.lang`.
假设我们有两个功能完善的语言文件:`xx_XX.lang` 和 `yy_YY.lang`。
<CodeHeader>RP/texts/languages.json</CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
[
"xx_XX",
"yy_YY"
]
```
`language_names.json` is an array as well, but this time to define the names to display for the languages.
<CodeHeader>RP/texts/language_names.json</CodeHeader>
```json
[
[ "xx_XX", "New Language (Custom Language #1)" ],
[ "yy_YY", "Wiki-Speak (Custom Language #2)" ]
]
```
:::warning
Whenever using a custom language, make sure to unequip the language before you disable the Resource Pack which it is stored in, or else Minecraft will crash.
:::
### Vanilla Languages
`language_names.json` 用于定义语言在选项菜单中的显示名称:
The following is a table of the 29 languages Minecraft supports by default.
::: code-group
```json [原始CodeHeader的值]
[
[ "xx_XX", "新语言(自定义语言 #1" ],
[ "yy_YY", "维基语(自定义语言 #2" ]
]
```
:::
| File ID | Language | Country |
| ---------- | --------------------- | -------------- |
| id_ID | Indonesian | Indonesia |
| da_DK | Danish | Denmark |
| de_DE | German | Germany |
| en_GB | English | Great Britain |
| en_US | English | North America |
| es_ES | Spanish | Spain |
| es_MX | Mexican Spanish | Mexico |
| fr_CA | Canadian French | Canada |
| fr_FR | French | France |
| it_IT | Italian | Italy |
| hu_HU | Hungarian | Hungary |
| nl_NL | Dutch | Netherlands |
| nb_NO | Bokmål | Norway |
| pl_PL | Polish | Poland |
| pt_BR | Brazilian Portuguese | Brazil |
| pt_PT | Portuguese | Portugal |
| sk_SK | Slovak | Slovakia |
| fi_FI | Finnish | Finland |
| sv_SE | Swedish | Sweden |
| tr_TR | Turkish | Turkey |
| cs_CZ | Czech | Czech Republic |
| el_GR | Greek | Greece |
| bg_BG | Bulgarian | Bulgaria |
| ru_RU | Russian | Russia |
| uk_UA | Ukrainian | Ukraine |
| ja_JP | Japanese | Japan |
| zh_CN | Chinese (Simplified) | China |
| zh_TW | Chinese (Traditional) | Taiwan |
| ko_KR | Korean | Korea |
:::warning
使用自定义语言时,在禁用其所属资源包前请先切换回其他语言,否则可能导致游戏崩溃。
:::
### 原版支持语言
下表列出了 Minecraft 默认支持的 29 种语言:
| 文件ID | 语言 | 国家/地区 |
| ---------- | ------------------- | --------------- |
| id_ID | 印度尼西亚语 | 印度尼西亚 |
| da_DK | 丹麦语 | 丹麦 |
| de_DE | 德语 | 德国 |
| en_GB | 英语 | 英国 |
| en_US | 英语 | 北美 |
| es_ES | 西班牙语 | 西班牙 |
| es_MX | 墨西哥西班牙语 | 墨西哥 |
| fr_CA | 加拿大法语 | 加拿大 |
| fr_FR | 法语 | 法国 |
| it_IT | 意大利语 | 意大利 |
| hu_HU | 匈牙利语 | 匈牙利 |
| nl_NL | 荷兰语 | 荷兰 |
| nb_NO | 书面挪威语 | 挪威 |
| pl_PL | 波兰语 | 波兰 |
| pt_BR | 巴西葡萄牙语 | 巴西 |
| pt_PT | 葡萄牙语 | 葡萄牙 |
| sk_SK | 斯洛伐克语 | 斯洛伐克 |
| fi_FI | 芬兰语 | 芬兰 |
| sv_SE | 瑞典语 | 瑞典 |
| tr_TR | 土耳其语 | 土耳其 |
| cs_CZ | 捷克语 | 捷克共和国 |
| el_GR | 希腊语 | 希腊 |
| bg_BG | 保加利亚语 | 保加利亚 |
| ru_RU | 俄语 | 俄罗斯 |
| uk_UA | 乌克兰语 | 乌克兰 |
| ja_JP | 日语 | 日本 |
| zh_CN | 简体中文 | 中国 |
| zh_TW | 繁体中文 | 台湾地区 |
| ko_KR | 韩语 | 韩国 |