BigWalkLocalizationAPI
BigWalkLocalizationAPI is a shared localization API for Big Walk mods.
模組介紹 作者原文
Note: This description is bilingual. The Chinese section is provided below the English section.
說明:本描述爲中英雙語版本,中文內容位於英文內容下方。
BigWalkLocalizationAPI (English)
BigWalkLocalizationAPI is a shared localization API for Big Walk mods.
What This Mod Does
- Loads external JSON localization files for individual mods.
- Uses Big Walk's active language and raises a language-change event for mod UI.
- Provides one-call localization for config sections, names, descriptions, and enum or list values.
For Players
This mod is an API/dependency. It does not add gameplay features by itself.
Install it only when another Big Walk mod lists BigWalkLocalizationAPI as a requirement.
For Mod Authors
Reference BigWalkLocalizationAPI.dll and add a hard dependency:
using System;
using System.IO;
using System.Reflection;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Unity.IL2CPP;
using BigWalkLocalizationAPI.Api;
[BepInPlugin(PluginInfo.PLUGIN_GUID, "My Mod", "1.0.0")]
[BepInDependency(BigWalkLocalizationAPI.PluginInfo.PLUGIN_GUID)]
public sealed class MyPlugin: BasePlugin
{
public override void Load()
{
string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
ModLocalizer localizer = LocalizationApi.For(PluginInfo.PLUGIN_GUID);
localizer.RegisterJson(Path.Combine(directory, "MyMod.Localization.json"));
Config.Bind("General", "Enabled", true, I18n.Localizer.Config("config.enabled", 20, "General", "config.section.general", 10));
LocalizationApi.LanguageChanged += OnLanguageChanged;
}
private static void OnLanguageChanged(string language)
{
// Refresh this mod's existing UI text here.
}
}
Load the JSON file from the directory containing your mod DLL. This works with generated mod-manager folder names:
using System.IO;
using System.Reflection;
using BigWalkLocalizationAPI.Api;
internal static class I18n
{
private const string FileName = "MyMod.Localization.json";
private static readonly ModLocalizer _localizer = Load();
internal static ModLocalizer Localizer
{
get { return _localizer; }
}
internal static string Text(string key, params object args)
{
return _localizer.GetLocalizedText(key, args);
}
private static ModLocalizer Load()
{
string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
ModLocalizer localizer = LocalizationApi.For(PluginInfo.PLUGIN_GUID);
localizer.RegisterJson(Path.Combine(directory, FileName));
return localizer;
}
}
The Config call uses the config section and key to find localized names, descriptions, and enum or acceptable-list values. Values are normalized to lowercase snake_case suffixes. Numeric ranges can also pass an optional sliderStep for Mod Settings Menu:
Config.Bind("General", "Mode", MyMode.SafeMode, I18n.Localizer.Config("config.mode", 20, "General", "config.section.general", 10));
Config.Bind("General", "Speed", 1f, I18n.Localizer.Config("config.speed", 30, "General", "config.section.general", 10, new AcceptableValueRange(0.5f, 3f), sliderStep: 0.25d));
Single JSON file example:
{
"English": {
"config.section.general": "General",
"config.mode.name": "Mode",
"config.mode.description": "Select the operating mode.",
"config.mode.safe_mode": "Safe"
},
"SimplifiedChinese": {
"config.section.general": "常規",
"config.mode.name": "模式",
"config.mode.description": "選擇運行模式。",
"config.mode.safe_mode": "安全"
}
}
Every localization file must contain an English object. If the current language or requested key is missing, the API tries English; if the key is still missing, it returns the key itself.
Supported Language Names
- English: English
- French: French
- Italian: Italian
- German: German
- European Spanish: EuropeanSpanish
- Simplified Chinese: SimplifiedChinese
- Japanese: Japanese
- Russian: Russian
- Korean: Korean
- Brazilian Portuguese: BrazilianPortuguese
- Polish: Polish
- Turkish: Turkish
- Czech: Czech
- Latin American Spanish: LatinAmericanSpanish
- Traditional Chinese: TraditionalChinese
Compatibility
安裝與使用 安裝:按包內說明操作
- 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
- 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
- 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
- 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。
不同模組的安裝位置差異較大,包內說明是最可靠的依據。
下面這些內容需要先安裝,否則該模組不會生效: