BepisLocaleLoader
Loads locale files for Plugins
模組介紹 作者原文
BepisLocaleLoader
A Resonite mod that Loads locale files for Plugins.
Installation (Manual)
- Install BepisLoader for Resonite.
- Download the latest release ZIP file (e.g., ResoniteModding-BepisLocaleLoader-1.0.0.zip) from the Releases page.
- Extract the ZIP and copy the plugins folder to your BepInEx folder in your Resonite installation directory:
- Default location: C:\Program Files (x86)\Steam\steamapps\common\Resonite\BepInEx\
- Start the game. If you want to verify that the mod is working you can check your BepInEx logs.
Example config using ConfigDescription
You can add locale to a config entry by adding a ConfigLocale in your ConfigDescription like this:
private static ConfigEntry exampleConfigItem;
public override void Load()
{
exampleConfigItem = Config.Bind("General", "exampleConfigItem", false, new ConfigDescription("exampleConfigItem Description", null, new ConfigLocale("Settings.dev.author.myPlugin.General.exampleConfigItem", "Settings.dev.author.myPlugin.General.exampleConfigItem.Description")));
}
Or you can use the ConfigLocaleHelper class which provides the BindLocalized extension method like this:
private static ConfigEntry exampleConfigItem;
public override void Load()
{
// Generates the following locale keys:
// Name: "Settings.dev.author.myPlugin.General.exampleConfigItem"
// Description: "Settings.dev.author.myPlugin.General.exampleConfigItem.Description"
exampleConfigItem = Config.BindLocalized("dev.author.myPlugin", "General", "exampleConfigItem", false, "exampleConfigItem Description");
// NOTE: If you are using the ResoniteModding plugin template you can use PluginMetadata.GUID instead of "dev.author.myPlugin"
}
When defining config entries with locale, it's still recommended to provide the entry's english description ("exampleConfigItem Description" in this case), as this will be visible when editing the config file manually or via mod managers.
Adding Locale Strings Manually
You can register a single localized string in code with:
LocaleLoader.AddLocaleString(
"Settings.BepInEx.Core.Config",
"Reset Configuration",
force: true,
authors: "YourName"
);
- rawString → The key used to look up the string.
- localeString → The localized text to display.
- force → If true, always overwrites existing entries.
- authors → Optional, comma-separated string of authors. Defaults to plugin authors or "BepInEx".
Loading Locale Files from a Plugin
Place a Locale folder next to your plugin DLL (e.g. MyPlugin/Locale/en.json).
Files should follow the LocaleData JSON structure:
{
"localeCode": "en-US",
"authors": ["MyName"],
"messages": {
"Settings.dev.author.myPlugin": "My Plugin",
"Settings.dev.author.myPlugin.Breadcrumb": "My Plugin Settings Breadcrumb Title",
"Settings.dev.author.myPlugin.config.Key": "Example Config Key",
"Settings.dev.author.myPlugin.config.Description": "Example Config Description."
}
}
String Shorthand:.T()
To make localization calls cleaner, LocaleLoader defines extension methods.T() that wrap AsLocaleKey and LocaleString.
Examples:
// Basic key lookup
"Settings.MyPlugin.Option".T();
// Key with formatting arguments
"Settings.MyPlugin.Welcome".T("Hello {name}!", "name", userName);
// Multiple arguments
"Settings.MyPlugin.Stats".T(
("kills", killCount),
("deaths", deathCount)
);
// With format string
"Settings.MyPlugin.Formatted".T("{kills}/{deaths}",
("kills", killCount),
("deaths", deathCount)
);
// Continuous locale updates (useful for dynamic UI)
"Settings.MyPlugin.Timer".T(
continuous: true,
arguments: new Dictionary { { "time", elapsedTime } }
);
When to Use force: true
- Use force: false (default) when you want to avoid overwriting existing locales (safe for mods adding only new keys).
- Use force: true when your plugin should override existing translations (e.g. testing, fixes, or ensuring your text is applied).
Debugging
- Loaded plugin locales are tracked in LocaleLoader.PluginsWithLocales.
- Logs show which files are loaded and how m
安裝與使用 安裝:按包內說明操作
- 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
- 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
- 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
- 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。
不同模組的安裝位置差異較大,包內說明是最可靠的依據。
下面這些內容需要先安裝,否則該模組不會生效: