RomesteadLocalizationAPI
Romestead Localization API is a small dependency mod for Romestead mod authors. It lets mods register localized text through JSON files or embedded C# strings, then reapplies those strings automatical
模組介紹 作者原文
說明:本描述爲中英雙語版本,中文內容位於英文內容下方。\
Note: This description is bilingual. The Chinese section is provided below the English section.
Romestead Localization API (English)
Romestead Localization API is a small dependency mod for Romestead mod authors. It lets mods register localized text through JSON files or embedded C# strings, then reapplies those strings automatically when the game loads or changes language.
Main Features
- Supports one JSON file for all languages: locale -> key -> text
- Supports multiple JSON files, one language per file
- Supports embedded C# registration for small mods that do not want to ship JSON files
- Automatically scopes keys by the registering mod GUID, so short keys like mod.name and entry.enabled do not conflict between mods
- Provides a bound localizer object, so mod code can use I18n.L.Text("mod.name") instead of passing the GUID every time
- Reapplies registered strings after the game reloads localization data
- Falls back to English, then Simplified Chinese, then the first available text when the current language is missing
For Players
This mod is an API/dependency. It does not add gameplay features by itself.
Install it if another mod lists Romestead Localization API as a requirement.
For Mod Authors
Add a hard dependency and reference RomesteadLocalizationAPI.dll from your project.
using BepInEx;
using BepInEx.NET.Common;
[BepInDependency(RomesteadLocalizationAPI.PluginInfo.PLUGIN_GUID)]
public sealed class MyPlugin: BasePlugin
{
public override void Load()
{
I18n.L.RegisterJson(Path.Combine(Paths.PluginPath, "MyMod", "Localization.json"));
}
}
Create a tiny bound localizer class:
using RomesteadLocalizationAPI.Api;
namespace MyMod;
internal static class I18n
{
public static readonly RomesteadLocalizer L =
RomesteadLocalization.For(PluginInfo.PLUGIN_GUID);
}
Single JSON file example:
{
"en": {
"mod.name": "My Mod",
"config.enabled.description": "Master switch for this mod."
},
"zh_CN": {
"mod.name": "我的模組",
"config.enabled.description": "這個模組的總開關。"
}
}
Use text in code:
var name = I18n.L.Text("mod.name");
var count = I18n.L.Text("items.count", itemCount);
Embedded text example:
I18n.L.RegisterTexts(
(RomesteadLocales.English, "mod.name", "My Mod"),
(RomesteadLocales.ChineseSimplified, "mod.name", "我的模組"));
A standalone HTML usage guide is included in the download as usage-guide.html.
Supported Locale Codes
- English: en
- Simplified Chinese: zh_CN
- Traditional Chinese: zh_TW
- Czech: cs_CZ
- German: de_DE
- Greek: el_GR
- Spanish: es_ES
- French: fr_FR
- Italian: it_IT
- Japanese: ja_JP
- Korean: ko_KR
- Dutch: nl_NL
- Polish: pl_PL
- Portuguese (Brazil): pt_BR
- Portuguese (Portugal): pt_PT
- Russian: ru_RU
- Slovak: sk_SK
- Swedish: sv_SE
- Thai: th_TH
- Turkish: tr_TR
- Ukrainian: uk_UA
Compatibility
- Game version: 0.25.1_10+
Bug Reports & Feature Suggestions
If you have any questions or feature suggestions, please submit them through GitHub Issues, or contact me directly at 764884112@qq.com or ibox2333@gmail.com.
Romestead Localization API (中文)
Romestead Localization API 是給 Romestead 模組作者使用的小型依賴模組。它可以讓模組通過 JSON 文件或 C# 內嵌字符串註冊本地化文本,並在遊戲加載或切換語言後自動重新應用這些文本。
主要功能
- 支持單 JSON 文件管理所有語言:語言 -> key -> 文本
- 支持多 JSON 文件,每個文件對應一種語言
- 支持 C# 內嵌文本註冊,適合不想額外攜帶 JSON 的小模組
- 註冊時自動按模組 GUID 隔離 key,因此 mod.name、entry.enabled 這類短 key 不會在不同模組之間衝突
- 提供綁定後的 localizer 對象,模組代碼可以寫 I18n.L.Text("mod.name"),不需要每次傳 GUID
- 遊戲重新加載本地化數據後,會自動重新應用模組文本
- 當前語言缺失時,按英文、簡體中文、任意可用文本順序回退
給玩家
這是一個 API/依賴模組,本身不會添加玩法內容。
如果其他模組要求安裝 Romestead Localization API,請安裝它。
給模組作者
添加硬依賴,並在項目中引用 RomesteadLocalizationAPI.dll。
using BepInEx;
using BepInEx.NET.Common;
[BepInDependency(RomesteadLocalizationAPI.PluginInfo.PLUGIN_GUID)]
public sealed class MyPlugin: BasePlugin
{
public override void Load()
{
I18n.L.RegisterJson(Path.Combine(Paths.PluginPath, "MyMod", "Localization.json"));
}
}
創建一個很小的綁定類:
using RomesteadLocalizationAPI.Api;
namespace MyMod;
internal static class I18n
{
public static readonly RomesteadL
安裝與使用 安裝:按包內說明操作
- 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
- 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
- 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
- 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。
不同模組的安裝位置差異較大,包內說明是最可靠的依據。
下面這些內容需要先安裝,否則該模組不會生效: