本地化

本页面讲述的内容长期有效
(重定向自Localisation

钢铁雄心4使用修改过的其他许多P社游戏使用的YAML本地化localization)系统。

基础

基本的格式如下:

l_<language>:
 <key>: "Text here"

空格可以省略。

一般来说你都会想使用l_englishkey指的是你要本地化的事物的脚本名称。

进阶的格式如下所示:

l_<language>:
 <key>:<number> "Text here"

这里是一个装备的本地化文件的实例:

l_english:
 infantry_equipment: "Infantry Equipment"
 infantry_equipment_short: "Inf. Eq."
 infantry_equipment_desc: "This is infantry equipment"

增加本地化语句时语法要准确,否则解析器会break而你得到的会是残缺的本地化。

.yml格式的文件是一种简单的文本文件,想要保存这种文件只需要选择保存为任意格式,然后输入.yml 后缀。

确保.yml文件使用UTF-8-BOM编码。使用Notepad++或是其他类似的项目可以很简单地查看和修改这一项。

特殊字符

引号

如果使用方式不正确,文本中的引号可能会导致文件的错误中断。

l_english:
 example_key: "This is "my quote" within a string."

这个例子不能正确读取,因为解析器会把第二个引号认为是字符串的结尾。

为了避免这种事情发生,引号需要与\符号配合使用。

l_english:
 example_key: "This is \"my quote\" within a string."

在游戏中,\符号并不会显示。

换行

你可能想要在显示的时候强制换行。想要做到这一点,在想要换行的地方使用\n即可。

l_english:
 example_key: "This is line 1\nThis is line 2\nThis line 3."

格式符号

有许多特殊符号可以在文本中改变字符串在游戏里的外观。

下列格式符号可以生效:

Code Effect
§% 把后面的值转换成百分数
§* 把后面的值转换成国际单位制
§= 如果后面的值为正,则添加+号;如果为负,添加-号
§0..9 控制小数点后显示的位数
§W 使文本变为白色
§G 使文本变为绿色
§R 使文本变为红色
§B 使文本变为蓝色
§Y 使文本变为黄色
§b 使文本变为黑色
§C 使文本变为浅蓝色(青色)
§g 使文本变为灰色
§T 使文本变为蓝绿色
§l 使文本变为淡绿色
§H 使文本变为黄色(与§Y作用相同)
§O 使文本变为橙色
§+ 如果后面的值为正,则使数值变为绿色;若为0,变为黄色;若为负,变为红色
§- 如果后面的值为正,则使数值变为红色;若为0,变为黄色;若为负,变为绿色
§! 结束目前的格式规则

这是一个颜色格式的例子:

l_english:
 example_key: "This is my text, §Bthis text is blue§!, and §Rthis text is red§!"

格式化变量

当对变量而不是普通的字符串进行格式化时,格式符号应加在|符号后面,例如:

[?party_popularity@democracy|%G0]

这样的本地化语句的效果是:它显示当前作用域的民主主义支持度,格式为百分数(%),绿色(G),四舍五入到个位(0,即小数点后0位)。

文本图标

使用£符号能显示文本图标

l_english:
 example_key: "£army_experience"

文本图标默认在 texticons.gfx 文件内定义,当然也能创建新的gfx文件来定义

覆盖字符串

有时候你不想创建新的本地化文件,而是想覆盖原版的本地化文件。在本地化文件夹中创建文件可能不会导致每个字符都被覆盖,因此您必须在本地化文件夹中创建名为“replace”的子文件夹(它必须命名为replace,其他子文件夹不会被读取)。在这个子文件夹中,你可以把文件和你想要重写的字符放在一起(例如,如果要重命名某个国家的党派,则需要创建一个名为new_parties.yml的文件,并将其放在本地化文件夹内的replace文件夹中)

动态文本

在特定的文本,比如说事件中,可以使用动态文本。这个操作会以面向对象的方式在特定的作用域内使用特殊的功能。(其实就是通过动态文本来获取游戏内一些变化的文本)

l_english:
 example_key: "[Root.GetName]"

This would grab the name of the ROOT scope and display it as the string.

It is possible to string scopes together:

l_english:
 example_key: "[From.Owner.GetName]"

This would grab the name of the OWNER (country) scope of the FROM (province) scope for the current ROOT (country) scope, and display it as the string.

Another example would be getting the capital:

l_english:
 example_key: "[Root.Capital.GetName]"

你可以使用国家Tag:

l_english:
 example_key: "[HUN.GetRulingParty]"

你也可以使用Event targets:

l_english:
 example_key: "[was_attacked.GetName]"

可用的作用域有:

  • Owner
  • Capital
  • Root
  • From
  • Prev

功能

  • GetName
  • GetNameDef
  • GetAdjective
  • GetAdjectiveCap
  • GetLeader
  • GetRulingParty
  • GetRulingIdeology
  • GetRulingIdeologyNoun
  • GetPartySupport
  • GetLastElection
  • GetManpower
  • GetFactionName
  • GetFlag
  • GetNameWithFlag
  • GetCommunistParty
  • GetDemocraticParty
  • GetFascistParty
  • GetNeutralParty
  • GetDateText
  • GetDateString
  • GetDateStringShortMonth
  • GetDateStringNoHour
  • GetDateStringNoHourLong
  • GetYear
  • GetHerselfHimself
  • GetHerHis
  • GetSheHe
  • GetSheHeCap
  • GetRank
  • GetManchuriaPuppet
  • GetID
  • GetTag