模组本地化:修订间差异

本页面部分全部内容上次核对于3.1版本
(文本替换 - 替换“Category:Modding”为“Category:模组制作”)
无编辑摘要
 
(未显示同一用户的9个中间版本)
第1行: 第1行:
{{Version|3.1}}
{{Version|3.1}}
Localisation refers to the actual text presented to the player in events, menus, weaponry, stories, and any other string of text in any window in the game. Localisation files are saved as [[wikipedia:.yml|.yml]] in the localisation/ folder and should be encoded with [[wikipedia:UTF-8-BOM|UTF-8 with BOM]]. The naming convention for .yml files is '''<file>_l_<language>.yml''' where <file> is the name given for this group of localisations, and <language> is the language the localisation is for. Supported languages currently include Portuguese (''braz_por'') English (''english''), French (''french''), German (''german''), Polish (''polish''), Russian (''russian''), Spanish (''spanish''), and simplified Chinese (''simp_chinese'').
本地化是指在游戏内窗口实际呈现给玩家的文本,如事件、菜单、武器、故事等。本地化文件以.yml 的格式保存在localisation/folder 路径底下,且以[[wikipedia:UTF-8-BOM|UTF-8-BOM]] 的格式编码。[[wikipedia:.yml|.yml]]文件的命名惯例是'''< 文件名>_l_< 语言名>.yml''' ,其中< 文件名> 为这组本地化的名字,而< 语言名> 为本地化的目标语言。目前支持的语言有葡萄牙语(braz_por),英语(english),法语(french),德语(german),波兰语(polish),俄语(russian),西班牙语(spanish),以及简体中文(simp_chinese)。


Useful commands:
实用指令:
  reload text – reloads localisation table.
  reload text – 重新加载本地化目录。
  switchlanguage l_english – switches used language and reloads localisation table.
  switchlanguage l_english – 切换语言并重新加载本地化目录。


=== Creating Localisation Files ===
=== 创建本地化文件 ===
* In the root mod folder (not in common), create a folder named "''localisation''" spelled with an s. Note, some other paradox titles may use the Americanized "''localization''" with a z.
* 在模组的根文件夹(注意不在common里)创建一个名为“localisation”的文件夹。注意,在某些别的paradox游戏里用的可能是美式拼写、带有z的“localization”。
* Optionally, create language subfolders within the "''localisation''" folder. This is organizationally helpful but not required.
* (可选)在“localisation”文件夹中创建对应语言的子文件夹。这有助于管理,但不是必需的。
* Stellaris’s localisation files are encoded as UTF-8-BOM. They '''must be''' encoded in UTF-8-BOM, as even UTF-8 will fail to be parsed by Stellaris, and will not work.
* 群星的本地化文件是用UTF-8-BOM 编码的。UTF-8-BOM是''' 唯一可用''' 的编码方式,就算用UTF-8 编码也会导致群星无法解析从而不能使用。
* The easiest way to get the correct encoding is to copy an existing Stellaris .yml file and modify it.
* 正确编码的最简单做法是复制一个现成的群星.yml 文件,再直接对其进行编辑。
* Alternatively, simply create a standard text file and save it as .yml with UTF-8 with BOM encoding. Various text editors, such as [[wikipedia:Notepad++|Notepad++]] and [[wikipedia:Visual Studio Code|Visual Studio Code]], will allow you to manually save with encoding UTF-8 with BOM
* 作为替代,你也可以创建一个标准的空白文本文档,再以UTF-8-BOM 编码保存它。类似[[wikipedia:Notepad++|Notepad++]] [[wikipedia:Visual Studio Code|Visual Studio Code]] 这样的文本编辑器能让你手动将文件保存为UTF-8-BOM 编码格式。
* The file name must end in "''_l_<language>''", otherwise it will not be read.
* 文件名必须以'' “_l_< 语言名> '' 结尾,否则无法被读取。
* The first line of any localisation file must be <code>l_<language>:</code>, otherwise it will not be read.
* 任何本地化文件的第一行都必须是<code>l_<language>:</code> ,否则无法被读取。
* Example file name: <code>mod_buildings_l_english.yml</code>
* 范例文件名:<code>mod_buildings_l_english.yml</code>


Naming a YML file the same as a vanilla YML file will overwrite vanilla. Doing this is not recommended, unless you are trying to change (almost) all of the entries in the file. Localisation entries can be overwritten individually, by saving them in the "Replace" folder. See [[#Overwriting Vanilla Text|overwrite section]].
将YML文件命名为与一个原版YML文件相同会导致原版被覆盖。这么做并不推荐, 除非你打算改写文件内(几乎)所有的条目。本地化条目可以通过保存到“Replace”文件夹以单独进行覆盖,详见[[#Overwriting Vanilla Text| 覆盖原版文本]]


Unfortunately there is no mod-friendly fallback language feature, so if localisation keys are missing, these keys are simply displayed as text. Therefore, it is practice to simply duplicate the English files for all other languages (changed with appropriate header).
遗憾的是,游戏并没有适配模组的语言回滚功能。这意味着当本地化键值缺失时,键值会直接以文本形式呈现。因此,对应的做法是先直接把英语文件复制到其他所有语言里(改成合适的标题)。


=== File Encoding ===
=== 文件编码 ===
* Open the YML file using a text editor. Editors such as [https://www.notepad-plus-plus.org/ Notepad++] and [https://code.visualstudio.com/ Visual Studio Code] are recommended, however, if those aren't available, even standard Notepad will work.
* 使用一个文本编辑器打开YML文件。推荐使用类似[https://www.notepad-plus-plus.org/ Notepad++] [https://code.visualstudio.com/ Visual Studio Code] 这样的编辑器,如果上述软件不可用的话,普通的记事本也行。
* Convert the file to UTF-8 with BOM
* 将文件转码成UTF-8-BOM 的格式。
* If using Notepad++, go to menu bar, open the ''Encoding'' menu.
* 使用Notepad++ 时,前往菜单栏,打开'' 编码'' 界面。
* If using VSC, go to the bottom right corner and click on the encoding (<code>UTF-8</code> by default), then click Save with Encoding. Alternatively, it is possible to modify the settings so YML files created using VSC have ''UTF-8 with BOM'' encoding by default.
* 使用Visual Studio Code时,前往右下角并点击编码(默认为<code>UTF-8</code> ),再点击保存编码。作为替代,也可以通过改变设置来让VSC默认以''UTF-8-BOM'' 格式生成YML文件。
* If using Notepad, go to ''Save As…'', then change the encoding and save the file.
* 使用记事本时,前往'' 另存为...'' ,改变编码并保存文件。
** If the options listed are ''UTF-8'' and ''UTF-8 with BOM'' (or similar), use ''UTF-8 with BOM''.
** 如果列出来的选项中同时有UTF-8 和UTF-8 with BOM (或相似的名称),选用UTF-8-BOM
** If the options listed are ''UTF-8 without BOM'' and ''UTF-8'' (or similar), use ''UTF-8''.
** 如果列出来的选项中同时有UTF-8 和UTF-8 without BOM (或相似的名称),选用UTF-8 。【译注:即一定要带BOM】


=== Localisation Keys ===
=== 本地化键值 ===
  <nowiki>
  
l_<language>:
l_< 语言名>:
localisation_key_1: "Text String 1"
  localisation_key_1: " 文本1"
localisation_key_2: "Text String 2"</nowiki>
  localisation_key_2: " 文本2"
Individual localisation entries are called keys and are placed before the colon. Keys are the actual code that points to the localised text. The text itself itself is called a string. The key is to the left of the colon. The string of text that will display in game is to the right of the colon, listed within two quotation marks (" "). The colon is the separator.
每个单独的本地化条目被称为“键值”,位于冒号的左侧,是指向本地化文本的实际代码。而游戏内显示的文本则位于冒号的右侧,包夹在双引号("" )里。冒号是分隔符。


* The number seen in vanilla files right after the colon can be omitted, as it is only useful for Paradox’s internal translation tracking.<ref>https://twitter.com/Martin_Anward/status/1039175213773144066</ref>
* 原版文件中紧接在冒号后面的数字可以被忽略,那是Paradox内部用于跟踪翻译用的。<ref>https://twitter.com/Martin_Anward/status/1039175213773144066</ref>
* The file must contain <code>l_english:</code> (or equivalent for other languages) before any localization keys.
* 在出现任何本地化键值之前,文件必须先包含<code>l_english:</code> (或其他语言的相等形式)。
* Every entry after <code>l_english:</code> (or equivalent) must begin with whitespace (a space or a tab works).
*<code>l_english:</code> (或相等)之后的所有条目必须以空格开始(空格或tab都行)。
* Each string to be displayed in game is encased in quotation marks. To display quotation marks in game, input a backslash before each quotation mark (for example: <code>text \"name\"</code>)
* 所有要在游戏内显示的文本都被双引号所包裹。想在游戏内显示双引号的话,请在双引号前面加上反斜杠(例如:<code>text \"name\"</code> )。
* Note that the following unicode characters are invalid inside the localisation file and will generate a "?" instead: <code>„ “ ‚ ‘ – ” ’ … —</code>
* 注意以下这些unicode字符在本地化文件中是不可用的,会生成一个“? ”:<code>„ “ ‚ ‘ – ” ’ … —</code>


== Overwriting Vanilla Text ==
== 覆盖原版文本 ==
To overwrite vanilla localisation keys (or keys from other mods), create a folder named "replace" inside your "localisation" folder. Localisation files in this folder will load after all other localisation files, and overwrite any duplicate keys. In this way it is not necessary to overwrite entire localisation files, as individual key entries will be overwritten by the last loaded file, LIOS (Last in, only served). It is possible to overwrite localisation without a "replace" folder, however this is not a reliable method.
想要覆盖原版本地化键值(或其他模组的键值)时,在你的“localisation”文件夹底下创建一个名为“replace”的文件夹。该文件夹中的本地化文件的读取比其他所有本地化文件都晚,能覆盖掉任何重复的键值。这样做可以避免覆盖所有本地化文件,每个键值条目会单独被最后加载的文件所覆盖。不通过“replace”文件夹来覆盖本地化是可行的,但并不可靠。


== Bracket Commands ==
== 方括号指令 ==
Bracket commands (scoped localization statements) are enclosed in square brackets (<code>[ ]</code>), start with a primary scope, end with a text retrieval, and can have one or more secondary scopes in between. The fields are separated by periods (.). Text retrievals can be predefined (as per examples below), can mention [[Variables]] defined in the scope, or can be a scripted_loc (see common/scripted_loc/ files for examples). When writing "''scripted_loc''" entries, it’s important to note that these entries cannot themselves use bracket commands (i.e., a scripted_loc that includes <code>[Root.GetName]</code> will literally print <code>[Root.GetName]</code>).
方括号指令(范围本地化声明) 用方括号(<code>[ ]</code> )包裹,以一个主作用域为开头,一段检索用文本为结尾。中间可以包含一个或数个次作用域。目标之间用小数点号(. )分隔。文本检索可以提前定义(参考下方的例子),可以引用作用域中声明的变量,也可以是段scripted_loc【即带脚本的语言文件】(参考common/scripted_loc 底下的文件)。在写“''scripted_loc'' ”条目时,要注意这些条目本身不能用方括号指令(例如:一段带有<code>[Root.GetName]</code> 的scripted_loc会直接原封不动地显示<code>[Root.GetName]</code> )。


Note: if you want to use loc commands e.g. <code>log = [This.GetName]</code> in a [[scripted effect]] or [[scripted trigger|trigger]], you have to write it <code>\\[This.GetName]</code> or it will bug out (at the latest the second time you use one in the effect).
注意:如果你想在[[scripted effect|脚本效果]]或[[scripted trigger|触发器]]中使用例如 <code>log = [This.GetName]</code> 这样的本地化指令,你得把它写成<code>\\[This.GetName]</code> ,不然就会出错(至少会在效果中第二次使用时出现)。


In most cases, it is also possible to get the value of variables with <code>'[Scope.my_variable]'</code> and saved dates with <code>'[Scope.my_date_flag]'</code>.<sup>([[patch 3.1|''since 3.1'']])</sup>
大多数情况下可以通过<code>'[Scope.my_variable]'</code> 来获取变量的赋值,以及通过<code>'[Scope.my_date_flag]'</code> 来获取保存的日期。<sup>([[patch 3.1|'' 从3.1 '']])</sup>


Two consecutive opening square brackets <code>'[['</code> will escape it, making a single square bracket show up in text instead, i.e. <code>'[[example]'</code> in loc will display as '[example]' in-game.
两个连续的左方括号 <code>'[['</code> 会跳过指令,使一个单独的方括号呈现在文本里。例如文件中的<code>'[[ 范例]'</code> 会在游戏中显示为'[ 范例]'


There are also several unscoped commands: <code>GetDate, GetMidGameDate, GetLateGameDate, GetYear, LastKilledCountryName</code>.
有几条指令是无范围的:<code>GetDate, GetMidGameDate, GetLateGameDate, GetYear, LastKilledCountryName</code>


Following list is only a part of hardcoded scoped localization commands (it also does not include any scripted locs). A more complete list of commands can be found at <code>Stellaris\logs\script_documentation\localizations.log</code>.
下方表格只记录了一部分的硬编码范围本地化指令(也没有涉及任何脚本语言文件)。一份更详尽的代码名单可以在<code>Stellaris\logs\script_documentation\localizations.log</code> 里找到。


==== Primary Scopes ====
==== 主作用域 ====
{| class="wikitable"
{| class="wikitable"
|-
|-
! Command !! Example usage !! Comments
! 指令 !! 使用范例 !! 注释
|-
|-
| Root || [Root.GetName] || The event’s root scope
| Root || [Root.GetName] || 事件的根作用域
|-
|-
| This || [This.GetName] || The current scope
| This || [This.GetName] || 当前作用域
|-
|-
| From || [From.From.GetName] || The calling event’s root scope. For events further back in the call stack, From can also be used as a secondary scope
| From || [From.From.GetName] || 调用事件的作用域。对于调用栈中更早位置的事件,From也可以充当次作用域
|-
|-
| Prev || [Prev.From.GetName] || The previous scope. It is not obvious to me what Prev.From points to, but some project descriptions use it
| Prev || [Prev.From.GetName] || 上一个目标。我不清楚Prev.From 指向的是什么,不过有些项目的描述中有用到。
|-
|-
| <event target tag> || [mytarget.GetName] || [[Event target]] tags are used without preceding them with <code>event_target:</code> in localisation
| <event target tag> || [mytarget.GetName] || [[Event target|事件目标(Event target)]] 标签要在本地化文件中声明<code>event_target:</code> 后才能使用。
|-
|-
! colspan=3 style="font-size:small"| Diplomatic Promotions
! colspan=3 style="font-size:small"| 外交活动
|-
|-
| Actor || [Actor.GetAllianceName] || Used in diplomatic response messages. The faction initiating an action
| Actor || [Actor.GetAllianceName] || 用于外交回应消息,发起行动的一方
|-
|-
| Recipient || [Recipient.GetName] || Used in diplomatic response messages. The faction targeted by the action
| Recipient || [Recipient.GetName] || 用于外交回应消息,作为行动目标的一方
|-
|-
| Third_party || [Third_party.GetName] || Used in diplomatic response messages. A third party involved in the action
| Third_party || [Third_party.GetName] || 用于外交回应消息,行动中牵涉到的第三方
|}
|}


==== Secondary Scopes ====
==== 次作用域 ====
{| class="wikitable"
{| class="wikitable"
|-
|-
! Command !! Example usage !! Comments
! 指令 !! 使用范例 !! 注释
|-
|-
! colspan=3 style="font-size:small"| Country Promotions: Capital Ruler Heir Species Federation
! colspan=3 style="font-size:small"| 国家活动:首都/统治者/继承人/物种/联邦
|-
|-
| Capital || [Root.Capital.GetName] || The capital of the current country or sector
| Capital || [Root.Capital.GetName] || 当前国家或星区的首都


|-
|-
| Leader|| [Root.Leader.GetName] || The leader of the current scope (<small>fleet, country, federation, pop faction, first contact, espionage operation, spy network, sector</small>)
| Leader|| [Root.Leader.GetName] || 当前作用域的领导人(<small> 舰队、国家、联邦、人口派系、第一次接触、情报行动、间谍网、星区</small>
|-
|-
! colspan=3 style="font-size:small"| War Promotions
! colspan=3 style="font-size:small"| 战争活动
|-
|-
| MainAttacker || [This.MainAttacker.GetAllianceName] || The main attacker of the current scope (must be used in a war scope), used in war name formats
| MainAttacker || [This.MainAttacker.GetAllianceName] || 当前作用域的主进攻者(作用域必须是战争),在战争名称样式中使用。
|-
|-
| MainDefender || [This.MainDefender.GetSpeciesName] || The main defender of the current scope (must be a war scope), used in war name formats
| MainDefender || [This.MainDefender.GetSpeciesName] || 当前作用域的主防御者(作用域必须是战争),在战争名称样式中使用。
|-
|-
! colspan=3 style="font-size:small"| Planet Promotions: Owner System MoonOf Sector
! colspan=3 style="font-size:small"| 星球活动:拥有者/所在星系/卫星/星区
|-
|-
| Owner || [Root.Owner.GetName] || The current scope’s owner
| Owner || [Root.Owner.GetName] || 当前作用域的拥有者
|-
|-
| System || [Root.System.GetName] || The system where the primary scope is located
| System || [Root.System.GetName] || 主作用域所在的星系
|-
|-
| Planet || [Root.Planet.GetName] || The planet where the current scope is located (<small>pop, army, archaeological site, deposit, megastructure</small>)
| Planet || [Root.Planet.GetName] || 当前作用域所处的星球(<small> 人口、陆军、考古遗址、资源点、巨构建筑</small>
|}
|}


=== Text Retrieval ===
=== 检索用文本 ===
{| class="wikitable"
{| class="wikitable"
|-
|-
! Command !! Example usage !! Comments
! 指令 !! 使用范例 !! 注释
|-
|-
| GetAdj || [Root.GetAdj] || The adjective associated with the current scope
| GetAdj || [Root.GetAdj] || 当前作用域所关联的形容词
|-
|-
| GetAdjective || [Root.GetAdjective] || The adjective associated with the current scope
| GetAdjective || [Root.GetAdjective] || 当前作用域所关联的形容词
|-
|-
| GetAllianceName || [This.MainAttacker.GetAllianceName] || The name of the alliance the current scope belongs to
| GetAllianceName || [This.MainAttacker.GetAllianceName] || 当前作用域所属的军事同盟的名称
|-
|-
| GetControllerName|| [Root.GetControllerName] || Name of the current controller (known to work on planets)
| GetControllerName|| [Root.GetControllerName] || 当前控制者的名称(已知能对星球生效)
|-
|-
| GetClassName || [Root.GetClassName] || Name of the current planet class
| GetClassName || [Root.GetClassName] || 当前星球种类的名称
|-
|-
| GetFleetName || [Root.GetFleetName] || The name of the fleet associated with the current scope
| GetFleetName || [Root.GetFleetName] || 与当前作用域关联的舰队名称
|-
|-
| GetHeirName || [Root.GetHeirName] || The name of the current heir
| GetHeirName || [Root.GetHeirName] || 当前继承人的名字
|-
|-
| GetHeirTitle || [Root.GetHeirTitle] || The title of the current heir
| GetHeirTitle || [Root.GetHeirTitle] || 当前继承人的头衔
|-
|-
| GetHomeWorldName || [Root.GetHomeWorldName] || The name of the home world of the current scope
| GetHomeWorldName || [Root.GetHomeWorldName] || 当前作用域的母星名称
|-
|-
| GetLeaderName || [Root.GetLeaderName] || The name of the leader associated with the current scope
| GetLeaderName || [Root.GetLeaderName] || 与当前作用域关联的领袖名称
|-
|-
| GetName || [Root.GetName] || The name associated with the current scope
| GetName || [Root.GetName] || 与当前作用域关联的名称
|-
|-
| GetFirstName || [Root.GetFirstName] || The name first associated with the current scoped leader
| GetFirstName || [Root.GetFirstName] || 与当前作用域领袖关联的第一个名称
|-
|-
| GetSecondName || [Root.GetSecondName] || The second name associated with the current scoped leader
| GetSecondName || [Root.GetSecondName] || 与当前作用域领袖关联的第二个名称
|-
|-
| GetAge || [Root.GetAge] || The age of the scoped leader
| GetAge || [Root.GetAge] || 作用域领袖的年龄
|-
|-
| GetNamePlural || [Root.GetNamePlural] || The plural name associated with the current scope (must be a species)
| GetNamePlural || [Root.GetNamePlural] || 与当前作用域关联的复数称谓(必须是一个物种)
|-
|-
| GetNebula || [Root.GetNebula] || (unknown)
| GetNebula || [Root.GetNebula] || (未知)
|-
|-
| GetOwnerName || [Root.GetOwnerName] || Name of the current owner
| GetOwnerName || [Root.GetOwnerName] || 当前所有者的名称
|-
|-
| GetPersonalityName || [Root.GetPersonalityName] || Get the name of the current AI personality
| GetPersonalityName || [Root.GetPersonalityName] || 当前AI性格的名称
|-
|-
| GetPlanetMoon || [Root.GetPlanetMoon] || "planet" or "moon" depending on whether the current scope is a planet or moon
| GetPlanetMoon || [Root.GetPlanetMoon] || 返回“星球”或者“卫星”,取决于当前作用域是哪一种
|-
|-
| GetPlanetMoonCap || [Root.GetPlanetMoonCap] || "Planet" or "Moon" depending on whether the current scope is a planet or moon
| GetPlanetMoonCap || [Root.GetPlanetMoonCap] || 返回“星球”或者“卫星”,取决于当前作用域是哪一种【与上条区别在于英文首字母大写】
|-
|-
| GetPopFactionName || [Root.GetPopFactionName] || The name of the currently scoped pop’s faction
| GetPopFactionName || [Root.GetPopFactionName] || 当前作用域的人口派系的名称
|-
|-
| GetRandomSpeciesSound || [Root.GetRandomSpeciesSound] || A sound chosen randomly from a list of sounds associated with current scope’s species
| GetRandomSpeciesSound || [Root.GetRandomSpeciesSound] || 从当前作用域物种相关联的声音列表里随机选一个进行播放
|-
|-
| GetRegnalName || [Root.GetRegnalName] || The regnal name of the current scope
| GetRegnalName || [Root.GetRegnalName] || 当前作用域的尊称
|-
|-
| GetRulerName || [Root.GetRulerName] || The name of the ruler associated with the current scope
| GetRulerName || [Root.GetRulerName] || 当前作用域关联的统治者名称
|-
|-
| GetRulerTitle || [Root.GetRulerTitle] || The title of the ruler associated with the current scope
| GetRulerTitle || [Root.GetRulerTitle] || 当前作用域关联的统治者头衔
|-
|-
| GetSpeciesAdj || [Root.GetSpeciesAdj] || The adjective for the species of the current scope
| GetSpeciesAdj || [Root.GetSpeciesAdj] || 当前作用域的物种的形容词形式
|-
|-
| GetSpeciesClass || [Root.GetSpeciesClass] || The class to which the species of the current scope belongs
| GetSpeciesClass || [Root.GetSpeciesClass] || 当前作用域的物种所属类别
|-
|-
| GetSpeciesClassPlural || [Root.GetSpeciesClassPlural] || The plural of the current scope’s species’ clas
| GetSpeciesClassPlural || [Root.GetSpeciesClassPlural] || 当前作用域的物种所属类别的复数形式
|-
|-
| GetSpeciesMouthName || [Root.GetSpeciesMouthName] || The word for the current scope’s species’ mouth
| GetSpeciesMouthName || [Root.GetSpeciesMouthName] || 当前作用域的物种所属类别的嘴巴的名称
|-
|-
| GetSpeciesName || [Root.GetSpeciesName] || The name of the current scope’s species
| GetSpeciesName || [Root.GetSpeciesName] || 当前作用域的物种名称
|-
|-
| GetSpeciesNameCompliment || [From.GetSpeciesNameCompliment] || A compliment using the current scope’s species
| GetSpeciesNameCompliment || [From.GetSpeciesNameCompliment] || 用当前作用域物种的名字发出一条赞美
|-
|-
| GetSpeciesNameInsult || [From.From.GetSpeciesNameInsult] || An insult using the current scope’s species
| GetSpeciesNameInsult || [From.From.GetSpeciesNameInsult] || 用当前作用域物种的名字发出一条侮辱
|-
|-
| GetSpeciesNamePlural || [This.GetSpeciesNamePlural] || The plural of current scope’s species’ name
| GetSpeciesNamePlural || [This.GetSpeciesNamePlural] || 当前作用域物种名称的复数形式
|-
|-
| GetSpeciesNamePluralCompliment || [Root.SpeciesNamePluralCompliment] || A compliment using the plural of the current scope’s species’ name
| GetSpeciesNamePluralCompliment || [Root.SpeciesNamePluralCompliment] || 用当前作用域物种的复数称谓发出一条赞美
|-
|-
| GetSpeciesNamePluralInsult || [From.SpeciesNamePluralInsult] || An insult using the plural of the current scope’s species’ name
| GetSpeciesNamePluralInsult || [From.SpeciesNamePluralInsult] || 用当前作用域物种的复数称谓发出一条侮辱
|-
|-
| GetSpeciesHandName || [From.GetSpeciesHandName] || The word for the current scope’s species’ hand
| GetSpeciesHandName || [From.GetSpeciesHandName] || 描述当前作用域物种的手的词
|-
|-
| GetSpeciesMouthName || [From.GetSpeciesMouthName] || The word for the current scope’s species’ mouth
| GetSpeciesMouthName || [From.GetSpeciesMouthName] || 描述当前作用域物种的嘴的词
|-
|-
| GetSpeciesOrganName || [From.GetSpeciesOrganName] || The word for the current scope’s species’ internal organ
| GetSpeciesOrganName || [From.GetSpeciesOrganName] || 描述当前作用域物种的内部器官的词
|-
|-
| GetSpeciesSpawnName || [Root.GetSpeciesSpawnName || The word for the children of the current scope’s species
| GetSpeciesSpawnName || [Root.GetSpeciesSpawnName || 描述当前作用域物种的小孩的词
|-
|-
| GetSpeciesSpawnNamePlural || [Root.GetSpeciesSpawnNamePlural || The plural word for the children of the current scope’s species
| GetSpeciesSpawnNamePlural || [Root.GetSpeciesSpawnNamePlural || 当前作用域物种的小孩的复数称谓
|-
|-
| GetStarName || [Root.Capital.GetStarName] || The name of the star where the current scope is located
| GetStarName || [Root.Capital.GetStarName] || 当前作用域所在的恒星的名字
|-
|-
| GetHerHim || [admiral.GetHerHim] || Prints 'her' or 'him' based on the character’s gender.
| GetHerHim || [admiral.GetHerHim] || 按角色的性别输出“他”或“她”
|-
|-
| GetSheHe || [abducted_leader.GetSheHe] || Prints 'she' or 'he' based on the character’s gender.
| GetSheHe || [abducted_leader.GetSheHe] || 按角色的性别输出“他”或“她”
|-
|-
| GetSheHeCap || [abducted_leader.GetSheHeCap] || Prints 'She' or 'He' based on the character’s gender.
| GetSheHeCap || [abducted_leader.GetSheHeCap] || 按角色的性别输出“他”或“她”【与上条区别在于英文首字母大写】
|-
|-
| GetHomeWorldName || [Root.GetHomeWorldName] || The home world name of the selected country
| GetHomeWorldName || [Root.GetHomeWorldName] || 选中国家的母星名称
|-
|-
| GetHerHis || [admiral.GetHerHis] || Prints 'her' or 'his’ based on the character’s gender.
| GetHerHis || [admiral.GetHerHis] || 按角色的性别输出“他的”或“她的”
|-
|-
| GetHerHisCap || [admiral.GetHerHisCap] || Prints 'Her' or 'His’ based on the character’s gender.
| GetHerHisCap || [admiral.GetHerHisCap] || 按角色的性别输出“他的”或“她的”【与上条区别在于英文首字母大写】
|-
|-
| LastKilledCountryName || [LastKilledCountryName] || Prints the name of the last killed country.
| LastKilledCountryName || [LastKilledCountryName] || 输出上一个所灭亡的国家名称
|}
|}


; Added localization commands with [[Patch 3.1]].
;[[Patch 3.1|补丁3.1]] 新增的本地化指令
  GetSpeciesFossilName
  GetSpeciesFossilName
  GetSpeciesFossilNamePlural
  GetSpeciesFossilNamePlural
第222行: 第222行:
  GetRemnantNamePlural
  GetRemnantNamePlural


== Color Codes ==
== 颜色代码 ==
[[File:Color codes in-game.png|thumb|Color codes in-game]]
[[File:Color codes in-game.png|thumb| 游戏内的颜色代码]]
Color codes start with <code>§</code> (Windows users Keypad shortcut: ALT+0167), which is followed by a single character specifying the color to be used until another color code is detected, or the end of the string: <code>§!</code>.  Within a '''<code>$</code>''' command, the color for a displayed variable (not string definition, s. below ''[[#$ Codes|$ Codes]]'') may also be specified by preceding the closing '''<code>$</code>''' with '''<code>{{!}}</code>''' and the color code character: <code>$AGE|Y$</code>
颜色代码以<code>§</code> 作开头(Windows快捷键:ALT+0167 ),后面跟着一个单一字母来指定所用的颜色,直到检测到另一个颜色代码,或以<code>§!</code> 结尾为止。指令'''<code>$</code>''' 代表着当前显示的变量的颜色(不是字符串定义,详见''[[#$ Codes| 代码$]]'' ),也能通过用'''<code>{{!}}</code>''' 以及颜色代码字母来隔开一对闭合的'''<code>$</code>''' 以指定颜色,如:<code>$AGE|Y$</code>


It is also possible to change the text color in game by adding a DC1 UTF-8 character to a color code letter. Please note that doing so may unintentionally color subsequent text if the color is not changed to default at the end.
你也可以通过在颜色代码字母中加入一个DC1 UTF-8 字符来改变游戏中的文本颜色。请注意这样做后如果没有把颜色改回默认,你可能会不小心使所有后续文本着色。
<code>§RR§Sa§Hi§Yn§Gb§Bo§Mw§!</code> <!-- Editor's note: You cannot get dc1 that easily, can't use &#17; &#x11; just to preview it --> will be displayed as:<span style="color:#D2483B">R</span><span style="color:#B07921">a</span><span style="color:#D69123">i</span><span style="color:#D2D62C">n</span><span style="color:#23BF20">b</span><span style="color:#2B8ED9">o</span><span style="color:#8B2DCB">w</span>
<code>§RR§Sa§Hi§Yn§Gb§Bo§Mw§!</code> <!-- Editor's note: You cannot get dc1 that easily, can't use &#17; &#x11; just to preview it --> 会被显示成:<span style="color:#D2483B">R</span><span style="color:#B07921">a</span><span style="color:#D69123">i</span><span style="color:#D2D62C">n</span><span style="color:#23BF20">b</span><span style="color:#2B8ED9">o</span><span style="color:#8B2DCB">w</span>


{| class="wikitable sortable"
{| class="wikitable sortable"
! Code !! Color !! Vanilla Use
! 代码 !! 颜色 !! 原版用法
|-
|-
| W || <b style="color:#DCDCDC">White</b> || Diplomatic Attitudes
| W || <b style="color:#DCDCDC"> 白色</b> || 外交态度
|-
|-
| T || <b style="color:#D9D9D9">Light grey</b> || Standard color of all text
| T || <b style="color:#D9D9D9"> 浅灰色</b> || 所有文本的标准颜色
|-
|-
| L || <b style="color:#9E8F75">Brown</b> || Lore, back story, role playing elements
| L || <b style="color:#9E8F75"> 棕色</b> || 传说、背景故事、角色扮演元素
|-
|-
| P || <b style="color:#BF5E5E">Light red</b> || Highlighting of Aggressive text in descriptions and event text
| P || <b style="color:#BF5E5E"> 淡红色</b> || 在描述和事件文本中高亮显示充满敌意的文本
|-
|-
| R || <b style="color:#D2483B">Red</b> || Negative modifiers
| R || <b style="color:#D2483B"> 红色</b> || 负面修正
|-
|-
| S || <b style="color:#B07921">Dark orange</b> || Subtle highlighted text
| S || <b style="color:#B07921"> 暗橙色</b> || 含蓄的高亮文本
|-
|-
| H || <b style="color:#D69123">Orange</b> || Highlighted text
| H || <b style="color:#D69123"> 橙色</b> || 高亮文本
|-
|-
| Y || <b style="color:#D2D62C">Yellow</b> || Sub-optimal or Neutral modifiers
| Y || <b style="color:#D2D62C"> 黄色</b> || 欠佳或中性的修正
|-
|-
| G || <b style="color:#23BF20">Green</b> || Positive modifiers
| G || <b style="color:#23BF20"> 绿色</b> || 正面修正
|-
|-
| E || <b style="color:#73D9B0">Teal</b> || Large chunks of text
| E || <b style="color:#73D9B0"> 青色</b> || 大块文本
|-
|-
| B || <b style="color:#2B8ED9">Blue</b> || Event effects that affect pops
| B || <b style="color:#2B8ED9"> 蓝色</b> || 影响人口的事件效果
|-
|-
| M || <b style="color:#8B2DCB">Purple</b> || Rare technologies
| M || <b style="color:#8B2DCB"> 紫色</b> || 稀有科技
|-
|-
| ! || Default || Return to color before last color change
| ! || 默认 || 回到上一次颜色变化之前的颜色
|}
|}


== $ Codes ==
== 代码$ ==
'''$''' is used to delimit strings (or variables) defined elsewhere to be expanded in the current string, or system statistics in GUI elements.
'''$''' 用于圈定在别处定义的字符串(或变量),将其拓展到当前字符串中,或GUI元素的系统统计数据里。


== Number Formatting ==
== 数字格式 ==
The | character can also be used to format numbers. <code>$VALUE|*x$</code> will format <code>VALUE</code> to <code>x</code> decimal places.
| 字符也能被用于调整数字的格式。<code>$VALUE|*x$</code> 会将<code>VALUE</code> 的小数点限定到<code>x</code> 位。
<pre>
# 范例 = 100
# EXAMPLE = 100
"$ 范例|*0$" # 100
"$EXAMPLE|*0$" # 100
"$ 范例|*1$" # 100.0
"$EXAMPLE|*1$" # 100.0
</pre>


== £ Codes ==
==  代码 £ ==
 £ codes are used for the names of various system stats, including energy, minerals, influence, and the three research categories (engineering, physics and society.) More exist than those listed here, such as <code>£ship_stats_hitpoints\armor\shield£</code>, <code>£fleet_template_size£</code>, and <code>£trigger_yes\no£</code> among others. Search the '£' character using something like Notepad++'s Find in Files feature to find something specific. Remember that  £ codes must surround the tag you're inserting, i.e. <code>'''£'''energy'''£'''</code>. (Windows users without the pound symbol on their keyboards can use <code>Alt + 0163</code>.)
  代码 £ 用于各种系统图标的名称,包括能量币、矿物、影响力,和三种研究类型(工程学、物理学、社会学)。还有更多没有列在此处,比如<code>£ship_stats_hitpoints\armor\shield£</code> <code>£fleet_template_size£</code> 以及<code>£trigger_yes\no£</code> 与其他种种。可以用类似于Notepad++ 的在文件中查找功能来搜索‘£’字符,以找到特定的某样东西。记住代码 £ 必须包围着你所感兴趣的标签,例如<code>'''£'''energy'''£'''</code> 。(没有英镑符号的Windows用户可以在键盘上按<code>Alt + 0163</code>


It also supports the multiple frames (if the source sprite has them), i.e.: <code>£leader_skill|3£</code> will render an icon of chosen skill level.
其同时也支持多框架(如果子来源有的话),例如:<code>£leader_skill|3£</code> 会渲染一个指定技能等级的图标。


{| class="wikitable sortable"
{| class="wikitable sortable"
|-
|-
! Code !! Picture
! 代码 !! 图片
|-
|-
| £energy£ || [[File:Energy Credits.png|40px]]
| £energy£ ||[[File:Energy Credits.png|40px]]
|-
|-
| £minerals£ || [[File:Minerals.png|40px]]
| £minerals£ ||[[File:Minerals.png|40px]]
|-
|-
| £food£ || [[File:Food.png|40px]]
| £food£ ||[[File:Food.png|40px]]
|-
|-
| £influence£ || [[File:Influence.png|40px]]
| £influence£ ||[[File:Influence.png|40px]]
|-
|-
| £stability£ || [[File:Stability.png|40px]]
| £stability£ ||[[File:Stability.png|40px]]
|-
|-
| £unity£ || [[File:Unity.png|40px]]
| £unity£ ||[[File:Unity.png|40px]]
|-
|-
| £alloys£ || [[File:Alloys.png|40px]]
| £alloys£ ||[[File:Alloys.png|40px]]
|-
|-
| £trade_value£ || [[File:Trade value.png|40px]]
| £trade_value£ ||[[File:Trade value.png|40px]]
|-
|-
| £physics£ || [[File:Physics Research.png|40px]]
| £physics£ ||[[File:Physics Research.png|40px]]
|-
|-
| £society£ || [[File:Society Research.png|40px]]
| £society£ ||[[File:Society Research.png|40px]]
|-
|-
| £engineering£ || [[File:Engineering Research.png|40px]]
| £engineering£ ||[[File:Engineering Research.png|40px]]
|-
|-
| £pops£ || [[File:Pop.png|40px]]
| £pops£ ||[[File:Pop.png|40px]]
|-
|-
| £happiness£ || [[File:Happiness.png|40px]]
| £happiness£ ||[[File:Happiness.png|40px]]
|-
|-
| £opinion£ || [[File:Opinion.png|40px]]
| £opinion£ ||[[File:Opinion.png|40px]]
|-
|-
| £empire£ || [[File:Empire Modifier.png|40px]]
| £empire£ ||[[File:Empire Modifier.png|40px]]
|-
|-
| £military_ship£ || [[File:Military Ship (icon).png|40px]]
| £military_ship£ ||[[File:Military Ship (icon).png|40px]]
|-
|-
| £military_power£ || [[File:offensive_value.png|40px]]
| £military_power£ ||[[File:offensive_value.png|40px]]
|-
|-
| £blocker£ || [[File:Tile Blocker.png|40px]]
| £blocker£ ||[[File:Tile Blocker.png|40px]]
|-
|-
| £time£ || [[File:Time.png|40px]]
| £time£ ||[[File:Time.png|40px]]
|-
|-
| £planetsize£ || [[File:Planet Size.png|40px]]
| £planetsize£ ||[[File:Planet Size.png|40px]]
|}
|}


== £ Custom Icons ==
== £ 自定义图标 ==
You can create custom text icons to appear in game exactly like those above, by saving an icon in ''<root>/gfx/interface/icons/text_icons''. Standard text icons are 16x16 pixel .dds files. In order to reference your icon in text, you will need to define it in the same way you define [[event pictures]]. Save a text file as .gfx in ''<root>/interface/'' Define any custom modifiers as shown below:
你可以创建在游戏内与上方图标表现一样的文本图标,通过把图标保存在''< 游戏根目录>/gfx/interface/icons/text_icons'' 里。标准的文本图标是尺寸为16x16像素点大小的.dds 文件。为了在文本中引用你的图标,你需要像定义[[event pictures|事件图片]] 一样定义它。将以下文本文档以.gfx 的格式保存到''< 游戏根目录>/interface/'' 里可以定义如下方所示的任何自定义修正:
<pre>
<pre>
spriteTypes = {
spriteTypes = {
第328行: 第326行:
      texturefile = "gfx/interface/icons/text_icons/mod_planet_jobs_worker_produces_mult.dds"
      texturefile = "gfx/interface/icons/text_icons/mod_planet_jobs_worker_produces_mult.dds"
    }</pre>
    }</pre>
You can link multiple icons by making separate <code>spriteType =</code> blocks. All of these should be within one larger <code>spriteTypes =</code> (with an s) block.
你可以通过多写几个<code>spriteType =</code> 区块来关联更多的图标。这些全部都应该处在<code>spriteTypes =</code> (多了一个s)的区块中。


The name must be prefixed <code>GFX_text_</code>. However, to reference this custom icon in localisation, use <code>£worker_produces_mult£</code> (without the prefix) and it will appear alongside in game text.
其名称必须以<code>GFX_text_</code> 为前缀。不过,如果是为了在本地化文件中引用它,用<code>£worker_produces_mult£</code> (没有前缀)就行,它会照常在游戏文本中出现。


== Slash-Based Codes ==
== 基于斜杠的代码 ==
The two slash-based codes available are <code>\n</code> and <code>\t</code>.<br>
两种可用的斜杠代码分别是<code>\n</code> <code>\t</code> <br>
<code>\n</code> is the equivalent of pressing the Enter key and starting a new line, unless it is inside one of the above codes.<br>
<code>\n</code> 等价于按下回车键并换行,除非它在上述代码的内部。<br>
<code>\t</code> places a tab.<br><br>
<code>\t</code> 生成一个制表符。<br><br>
Backslashes can also be used to treat special characters as text characters, for example <code>\"</code> will make the string contain a quotation mark, instead of closing it off.
斜杠同时也能用做将特殊字符还原为文本字符,比如<code>\"</code> 会让字符串带上一个双引号,而不是结束字符串。


== Style Guide ==
== 格式指导 ==
Vanilla events, modifiers and all other type of localization follows punctuation and capitalization guidelines. The following table highlights some of the rules employed in the vanilla English localization, allowing custom content to blend in more seamlessly. The table is by no means comprehensive, but instead should serve as a quick cheat-sheet for the most common type of strings.
原版活动、修正和所有其他类型的本地化都遵循一套标点符号与大小写的规范。下方表格标出了原版英文本地化中用到的一些规则,使玩家自订的内容能更好地融入其中。表格并不完善,但可用作大多数常用文本的快捷备忘单。给出的字符数量限制并不是硬性要求,不过视位置而定超出限制可能导致文本被截断,破坏UI布局,或单单溢出框外显得难看。
The number given for Character Limit is not a hard limit. Depending on the location, exceeding the limit might cause the text to be cut off, completely break the UI, or just look ugly and out of place.


{| class="wikitable"
{| class="wikitable"
|-
|-
! Location !! Capitalization !! Punctuation !! Character Limit !! Example
! 位置 !! 大小写 !! 标点符号 !! 字数限制 !! 范例
|-
|-
| Event Names || Title Case || None || 50 || "Exotic Woodwind"
| 事件名称 || 每个单词首字母大写 || || 50 || "Exotic Woodwind"
|-
|-
| Event Descriptions || Sentence case || Standard || 2000 || "Music has taken many forms among the beings we have encountered since leaving [Root.GetHomeWorldName], and the methods and preferences continue to baffle us. Sometimes alien […] Whatever this instrument is, it’s unlike any of our own."
| 事件描述 || 句首字母大写 || 标准 || 2000 || "Music has taken many forms among the beings we have encountered since leaving [Root.GetHomeWorldName], and the methods and preferences continue to baffle us. Sometimes alien […] Whatever this instrument is, it’s unlike any of our own."
|-
|-
| Event Options || Sentence case || Terminal punctuation || 70 || "An excellent time to learn more about their culture.", "Let us be careful and study this instrument.", "The colony is part of our future. It stays."
| 事件选项 || 句首字母大写 || 句尾终止式 || 70 || "An excellent time to learn more about their culture.", "Let us be careful and study this instrument.", "The colony is part of our future. It stays."
|-
|-
| Names for Traits/Modifiers/Buildings/Ethics/etc. || Title Case || None || 30 || "Building Cost", "Massive Crater", "Very Strong"
| 特质/ 修正/ 建筑/ 思潮等名称 || 每个单词首字母大写 || || 30 || "Building Cost", "Massive Crater", "Very Strong"
|-
|-
| Description for Traits/Modifiers/Buildings/Ethics/etc. || Sentence case || Standard || 200 || "The impact site of the meteorite which brought Lithoids to this planet.", "Members of this species possess a strength that almost defies the laws of physics."
| 特质/ 修正/ 建筑/ 思潮等描述 || 句首字母大写 || 标准 || 200 || "The impact site of the meteorite which brought Lithoids to this planet.", "Members of this species possess a strength that almost defies the laws of physics."
|-
|-
| UI Buttons || Sentence case / Title Case || None || Depends on UI || "Withdraw"
| UI 按钮 || 两者兼有 || || 取决于UI || "Withdraw"
|-
|-
| UI Alerts || Title Case || None || Depends on UI || "Relic Activation Available"
| UI 通知 || 每个单词首字母大写 || || 取决于UI || "Relic Activation Available"
|}
|}


== References ==
== 参考 ==
<references />
<references />


{{ModdingNavbox}}
{{ModdingNavbox}}
[[Category:模组制作]]
[[Category:模组制作]]

2022年6月6日 (一) 02:31的最新版本

本地化是指在游戏内窗口实际呈现给玩家的文本,如事件、菜单、武器、故事等。本地化文件以.yml的格式保存在localisation/folder路径底下,且以UTF-8-BOM的格式编码。.yml文件的命名惯例是<文件名>_l_<语言名>.yml,其中<文件名>为这组本地化的名字,而<语言名>为本地化的目标语言。目前支持的语言有葡萄牙语(braz_por),英语(english),法语(french),德语(german),波兰语(polish),俄语(russian),西班牙语(spanish),以及简体中文(simp_chinese)。

实用指令:

reload text – 重新加载本地化目录。
switchlanguage l_english – 切换语言并重新加载本地化目录。

创建本地化文件[编辑 | 编辑源代码]

  • 在模组的根文件夹(注意不在common里)创建一个名为“localisation”的文件夹。注意,在某些别的paradox游戏里用的可能是美式拼写、带有z的“localization”。
  • (可选)在“localisation”文件夹中创建对应语言的子文件夹。这有助于管理,但不是必需的。
  • 群星的本地化文件是用UTF-8-BOM编码的。UTF-8-BOM是唯一可用的编码方式,就算用UTF-8编码也会导致群星无法解析从而不能使用。
  • 正确编码的最简单做法是复制一个现成的群星.yml文件,再直接对其进行编辑。
  • 作为替代,你也可以创建一个标准的空白文本文档,再以UTF-8-BOM编码保存它。类似Notepad++Visual Studio Code这样的文本编辑器能让你手动将文件保存为UTF-8-BOM编码格式。
  • 文件名必须以“_l_<语言名>”结尾,否则无法被读取。
  • 任何本地化文件的第一行都必须是l_<language>:,否则无法被读取。
  • 范例文件名:mod_buildings_l_english.yml

将YML文件命名为与一个原版YML文件相同会导致原版被覆盖。这么做并不推荐, 除非你打算改写文件内(几乎)所有的条目。本地化条目可以通过保存到“Replace”文件夹以单独进行覆盖,详见覆盖原版文本

遗憾的是,游戏并没有适配模组的语言回滚功能。这意味着当本地化键值缺失时,键值会直接以文本形式呈现。因此,对应的做法是先直接把英语文件复制到其他所有语言里(改成合适的标题)。

文件编码[编辑 | 编辑源代码]

  • 使用一个文本编辑器打开YML文件。推荐使用类似Notepad++Visual Studio Code 这样的编辑器,如果上述软件不可用的话,普通的记事本也行。
  • 将文件转码成UTF-8-BOM的格式。
  • 使用Notepad++时,前往菜单栏,打开编码 界面。
  • 使用Visual Studio Code时,前往右下角并点击编码(默认为UTF-8),再点击保存编码。作为替代,也可以通过改变设置来让VSC默认以UTF-8-BOM 格式生成YML文件。
  • 使用记事本时,前往另存为...,改变编码并保存文件。
    • 如果列出来的选项中同时有UTF-8 和UTF-8 with BOM(或相似的名称),选用UTF-8-BOM。
    • 如果列出来的选项中同时有UTF-8 和UTF-8 without BOM(或相似的名称),选用UTF-8。【译注:即一定要带BOM】

本地化键值[编辑 | 编辑源代码]

l_<语言名>:
 localisation_key_1: "文本1"
 localisation_key_2: "文本2"

每个单独的本地化条目被称为“键值”,位于冒号的左侧,是指向本地化文本的实际代码。而游戏内显示的文本则位于冒号的右侧,包夹在双引号("")里。冒号是分隔符。

  • 原版文件中紧接在冒号后面的数字可以被忽略,那是Paradox内部用于跟踪翻译用的。[1]
  • 在出现任何本地化键值之前,文件必须先包含l_english: (或其他语言的相等形式)。
  • l_english:(或相等)之后的所有条目必须以空格开始(空格或tab都行)。
  • 所有要在游戏内显示的文本都被双引号所包裹。想在游戏内显示双引号的话,请在双引号前面加上反斜杠(例如:text \"name\")。
  • 注意以下这些unicode字符在本地化文件中是不可用的,会生成一个“?”:„ “ ‚ ‘ – ” ’ … —

覆盖原版文本[编辑 | 编辑源代码]

想要覆盖原版本地化键值(或其他模组的键值)时,在你的“localisation”文件夹底下创建一个名为“replace”的文件夹。该文件夹中的本地化文件的读取比其他所有本地化文件都晚,能覆盖掉任何重复的键值。这样做可以避免覆盖所有本地化文件,每个键值条目会单独被最后加载的文件所覆盖。不通过“replace”文件夹来覆盖本地化是可行的,但并不可靠。

方括号指令[编辑 | 编辑源代码]

方括号指令(范围本地化声明) 用方括号([ ])包裹,以一个主作用域为开头,一段检索用文本为结尾。中间可以包含一个或数个次作用域。目标之间用小数点号(.)分隔。文本检索可以提前定义(参考下方的例子),可以引用作用域中声明的变量,也可以是段scripted_loc【即带脚本的语言文件】(参考common/scripted_loc底下的文件)。在写“scripted_loc”条目时,要注意这些条目本身不能用方括号指令(例如:一段带有[Root.GetName]的scripted_loc会直接原封不动地显示[Root.GetName])。

注意:如果你想在脚本效果触发器中使用例如 log = [This.GetName] 这样的本地化指令,你得把它写成\\[This.GetName],不然就会出错(至少会在效果中第二次使用时出现)。

大多数情况下可以通过'[Scope.my_variable]'来获取变量的赋值,以及通过'[Scope.my_date_flag]'来获取保存的日期。(从3.1起)

两个连续的左方括号 '[[' 会跳过指令,使一个单独的方括号呈现在文本里。例如文件中的'[[范例]' 会在游戏中显示为'[范例]'。

有几条指令是无范围的:GetDate, GetMidGameDate, GetLateGameDate, GetYear, LastKilledCountryName

下方表格只记录了一部分的硬编码范围本地化指令(也没有涉及任何脚本语言文件)。一份更详尽的代码名单可以在Stellaris\logs\script_documentation\localizations.log里找到。

主作用域[编辑 | 编辑源代码]

指令 使用范例 注释
Root [Root.GetName] 事件的根作用域
This [This.GetName] 当前作用域
From [From.From.GetName] 调用事件的作用域。对于调用栈中更早位置的事件,From也可以充当次作用域
Prev [Prev.From.GetName] 上一个目标。我不清楚Prev.From指向的是什么,不过有些项目的描述中有用到。
<event target tag> [mytarget.GetName] 事件目标(Event target)标签要在本地化文件中声明event_target:后才能使用。
外交活动
Actor [Actor.GetAllianceName] 用于外交回应消息,发起行动的一方
Recipient [Recipient.GetName] 用于外交回应消息,作为行动目标的一方
Third_party [Third_party.GetName] 用于外交回应消息,行动中牵涉到的第三方

次作用域[编辑 | 编辑源代码]

指令 使用范例 注释
国家活动:首都/统治者/继承人/物种/联邦
Capital [Root.Capital.GetName] 当前国家或星区的首都
Leader [Root.Leader.GetName] 当前作用域的领导人(舰队、国家、联邦、人口派系、第一次接触、情报行动、间谍网、星区
战争活动
MainAttacker [This.MainAttacker.GetAllianceName] 当前作用域的主进攻者(作用域必须是战争),在战争名称样式中使用。
MainDefender [This.MainDefender.GetSpeciesName] 当前作用域的主防御者(作用域必须是战争),在战争名称样式中使用。
星球活动:拥有者/所在星系/卫星/星区
Owner [Root.Owner.GetName] 当前作用域的拥有者
System [Root.System.GetName] 主作用域所在的星系
Planet [Root.Planet.GetName] 当前作用域所处的星球(人口、陆军、考古遗址、资源点、巨构建筑

检索用文本[编辑 | 编辑源代码]

指令 使用范例 注释
GetAdj [Root.GetAdj] 当前作用域所关联的形容词
GetAdjective [Root.GetAdjective] 当前作用域所关联的形容词
GetAllianceName [This.MainAttacker.GetAllianceName] 当前作用域所属的军事同盟的名称
GetControllerName [Root.GetControllerName] 当前控制者的名称(已知能对星球生效)
GetClassName [Root.GetClassName] 当前星球种类的名称
GetFleetName [Root.GetFleetName] 与当前作用域关联的舰队名称
GetHeirName [Root.GetHeirName] 当前继承人的名字
GetHeirTitle [Root.GetHeirTitle] 当前继承人的头衔
GetHomeWorldName [Root.GetHomeWorldName] 当前作用域的母星名称
GetLeaderName [Root.GetLeaderName] 与当前作用域关联的领袖名称
GetName [Root.GetName] 与当前作用域关联的名称
GetFirstName [Root.GetFirstName] 与当前作用域领袖关联的第一个名称
GetSecondName [Root.GetSecondName] 与当前作用域领袖关联的第二个名称
GetAge [Root.GetAge] 作用域领袖的年龄
GetNamePlural [Root.GetNamePlural] 与当前作用域关联的复数称谓(必须是一个物种)
GetNebula [Root.GetNebula] (未知)
GetOwnerName [Root.GetOwnerName] 当前所有者的名称
GetPersonalityName [Root.GetPersonalityName] 当前AI性格的名称
GetPlanetMoon [Root.GetPlanetMoon] 返回“星球”或者“卫星”,取决于当前作用域是哪一种
GetPlanetMoonCap [Root.GetPlanetMoonCap] 返回“星球”或者“卫星”,取决于当前作用域是哪一种【与上条区别在于英文首字母大写】
GetPopFactionName [Root.GetPopFactionName] 当前作用域的人口派系的名称
GetRandomSpeciesSound [Root.GetRandomSpeciesSound] 从当前作用域物种相关联的声音列表里随机选一个进行播放
GetRegnalName [Root.GetRegnalName] 当前作用域的尊称
GetRulerName [Root.GetRulerName] 当前作用域关联的统治者名称
GetRulerTitle [Root.GetRulerTitle] 当前作用域关联的统治者头衔
GetSpeciesAdj [Root.GetSpeciesAdj] 当前作用域的物种的形容词形式
GetSpeciesClass [Root.GetSpeciesClass] 当前作用域的物种所属类别
GetSpeciesClassPlural [Root.GetSpeciesClassPlural] 当前作用域的物种所属类别的复数形式
GetSpeciesMouthName [Root.GetSpeciesMouthName] 当前作用域的物种所属类别的嘴巴的名称
GetSpeciesName [Root.GetSpeciesName] 当前作用域的物种名称
GetSpeciesNameCompliment [From.GetSpeciesNameCompliment] 用当前作用域物种的名字发出一条赞美
GetSpeciesNameInsult [From.From.GetSpeciesNameInsult] 用当前作用域物种的名字发出一条侮辱
GetSpeciesNamePlural [This.GetSpeciesNamePlural] 当前作用域物种名称的复数形式
GetSpeciesNamePluralCompliment [Root.SpeciesNamePluralCompliment] 用当前作用域物种的复数称谓发出一条赞美
GetSpeciesNamePluralInsult [From.SpeciesNamePluralInsult] 用当前作用域物种的复数称谓发出一条侮辱
GetSpeciesHandName [From.GetSpeciesHandName] 描述当前作用域物种的手的词
GetSpeciesMouthName [From.GetSpeciesMouthName] 描述当前作用域物种的嘴的词
GetSpeciesOrganName [From.GetSpeciesOrganName] 描述当前作用域物种的内部器官的词
GetSpeciesSpawnName [Root.GetSpeciesSpawnName 描述当前作用域物种的小孩的词
GetSpeciesSpawnNamePlural [Root.GetSpeciesSpawnNamePlural 当前作用域物种的小孩的复数称谓
GetStarName [Root.Capital.GetStarName] 当前作用域所在的恒星的名字
GetHerHim [admiral.GetHerHim] 按角色的性别输出“他”或“她”
GetSheHe [abducted_leader.GetSheHe] 按角色的性别输出“他”或“她”
GetSheHeCap [abducted_leader.GetSheHeCap] 按角色的性别输出“他”或“她”【与上条区别在于英文首字母大写】
GetHomeWorldName [Root.GetHomeWorldName] 选中国家的母星名称
GetHerHis [admiral.GetHerHis] 按角色的性别输出“他的”或“她的”
GetHerHisCap [admiral.GetHerHisCap] 按角色的性别输出“他的”或“她的”【与上条区别在于英文首字母大写】
LastKilledCountryName [LastKilledCountryName] 输出上一个所灭亡的国家名称
补丁3.1新增的本地化指令
GetSpeciesFossilName
GetSpeciesFossilNamePlural
GetSpeciesRemnantName
GetSpeciesRemnantNamePlural
Species
GetFossilName
GetFossilNamePlural
GetRemnantName
GetRemnantNamePlural

颜色代码[编辑 | 编辑源代码]

游戏内的颜色代码

颜色代码以§作开头(Windows快捷键:ALT+0167),后面跟着一个单一字母来指定所用的颜色,直到检测到另一个颜色代码,或以§!结尾为止。指令$代表着当前显示的变量的颜色(不是字符串定义,详见代码$ ),也能通过用|以及颜色代码字母来隔开一对闭合的$ 以指定颜色,如:$AGE|Y$

你也可以通过在颜色代码字母中加入一个DC1 UTF-8字符来改变游戏中的文本颜色。请注意这样做后如果没有把颜色改回默认,你可能会不小心使所有后续文本着色。 §RR§Sa§Hi§Yn§Gb§Bo§Mw§! 会被显示成:Rainbow

代码 颜色 原版用法
W 白色 外交态度
T 浅灰色 所有文本的标准颜色
L 棕色 传说、背景故事、角色扮演元素
P 淡红色 在描述和事件文本中高亮显示充满敌意的文本
R 红色 负面修正
S 暗橙色 含蓄的高亮文本
H 橙色 高亮文本
Y 黄色 欠佳或中性的修正
G 绿色 正面修正
E 青色 大块文本
B 蓝色 影响人口的事件效果
M 紫色 稀有科技
! 默认 回到上一次颜色变化之前的颜色

代码$[编辑 | 编辑源代码]

$ 用于圈定在别处定义的字符串(或变量),将其拓展到当前字符串中,或GUI元素的系统统计数据里。

数字格式[编辑 | 编辑源代码]

| 字符也能被用于调整数字的格式。$VALUE|*x$会将VALUE的小数点限定到x位。

# 范例 = 100
"$范例|*0$" # 100
"$范例|*1$" # 100.0

代码£[编辑 | 编辑源代码]

代码£用于各种系统图标的名称,包括能量币、矿物、影响力,和三种研究类型(工程学、物理学、社会学)。还有更多没有列在此处,比如£ship_stats_hitpoints\armor\shield££fleet_template_size£以及£trigger_yes\no£ 与其他种种。可以用类似于Notepad++的在文件中查找功能来搜索‘£’字符,以找到特定的某样东西。记住代码£必须包围着你所感兴趣的标签,例如£energy£。(没有英镑符号的Windows用户可以在键盘上按Alt + 0163

其同时也支持多框架(如果子来源有的话),例如:£leader_skill|3£会渲染一个指定技能等级的图标。

代码 图片
£energy£ Energy Credits.png
£minerals£ Minerals.png
£food£ Food.png
£influence£ Influence.png
£stability£ Stability.png
£unity£ Unity.png
£alloys£ Alloys.png
£trade_value£ Trade value.png
£physics£ Physics Research.png
£society£ Society Research.png
£engineering£ Engineering Research.png
£pops£ Pop.png
£happiness£ Happiness.png
£opinion£ Opinion.png
£empire£ Empire Modifier.png
£military_ship£ Military Ship (icon).png
£military_power£ Offensive value.png
£blocker£ Tile Blocker.png
£time£ Time.png
£planetsize£ Planet Size.png

£自定义图标[编辑 | 编辑源代码]

你可以创建在游戏内与上方图标表现一样的文本图标,通过把图标保存在<游戏根目录>/gfx/interface/icons/text_icons 里。标准的文本图标是尺寸为16x16像素点大小的.dds文件。为了在文本中引用你的图标,你需要像定义事件图片一样定义它。将以下文本文档以.gfx的格式保存到<游戏根目录>/interface/ 里可以定义如下方所示的任何自定义修正:

spriteTypes = {
   spriteType = {
        name = "GFX_text_worker_produces_mult"
        texturefile = "gfx/interface/icons/text_icons/mod_planet_jobs_worker_produces_mult.dds"
    }

你可以通过多写几个spriteType =区块来关联更多的图标。这些全部都应该处在spriteTypes =(多了一个s)的区块中。

其名称必须以GFX_text_为前缀。不过,如果是为了在本地化文件中引用它,用£worker_produces_mult£(没有前缀)就行,它会照常在游戏文本中出现。

基于斜杠的代码[编辑 | 编辑源代码]

两种可用的斜杠代码分别是\n\t
\n等价于按下回车键并换行,除非它在上述代码的内部。
\t生成一个制表符。

斜杠同时也能用做将特殊字符还原为文本字符,比如\"会让字符串带上一个双引号,而不是结束字符串。

格式指导[编辑 | 编辑源代码]

原版活动、修正和所有其他类型的本地化都遵循一套标点符号与大小写的规范。下方表格标出了原版英文本地化中用到的一些规则,使玩家自订的内容能更好地融入其中。表格并不完善,但可用作大多数常用文本的快捷备忘单。给出的字符数量限制并不是硬性要求,不过视位置而定超出限制可能导致文本被截断,破坏UI布局,或单单溢出框外显得难看。

位置 大小写 标点符号 字数限制 范例
事件名称 每个单词首字母大写 50 "Exotic Woodwind"
事件描述 句首字母大写 标准 2000 "Music has taken many forms among the beings we have encountered since leaving [Root.GetHomeWorldName], and the methods and preferences continue to baffle us. Sometimes alien […] Whatever this instrument is, it’s unlike any of our own."
事件选项 句首字母大写 句尾终止式 70 "An excellent time to learn more about their culture.", "Let us be careful and study this instrument.", "The colony is part of our future. It stays."
特质/修正/建筑/思潮等名称 每个单词首字母大写 30 "Building Cost", "Massive Crater", "Very Strong"
特质/修正/建筑/思潮等描述 句首字母大写 标准 200 "The impact site of the meteorite which brought Lithoids to this planet.", "Members of this species possess a strength that almost defies the laws of physics."
UI按钮 两者兼有 取决于UI "Withdraw"
UI通知 每个单词首字母大写 取决于UI "Relic Activation Available"

参考[编辑 | 编辑源代码]

帝国 帝国思潮政府 • 国民理念 • 起源承诺议程传统 • 飞升天赋法令政策遗珍科技自定义帝国
人口 岗位派系
领袖 领袖领袖特质
物种 物种物种特质
行星 行星行星特征 • 轨道矿藏建筑 • 区划行星决议
星系 星系恒星基地巨型结构虫洞 • 星门地图
舰队 舰队舰船 • 部件
地面战 陆军轰炸姿态
外交 外交 • 联邦 • 星海共同体评价修正宣战理由 • 战争目标
事件 事件异常现象特殊项目考古遗址
游玩 游玩定义研究 • 经济游戏开局
动态修改 动态指令效果触发条件作用域修正变量AI
媒体/本地化 Maya 导出器图形肖像旗帜事件图片界面图标音乐本地化
Other 控制台命令存档编辑Steam 创意工坊模组制作教程