HowtoFishLocalizationAPI
How to Fish Localization API is a shared dependency API for How to Fish mods. It lets compatible mods load their own language files and update their UI when the game language changes.
模組介紹 作者原文
Note: This description is bilingual. The Chinese section is provided below the English section.
說明:本描述爲中英雙語版本,中文內容位於英文內容下方。
How to Fish Localization API (English)
How to Fish Localization API is a shared dependency API for How to Fish mods. It lets compatible mods load their own language files and update their UI when the game language changes.
Main Features
- Loads an external JSON localization file for each compatible mod.
- Reads the active How to Fish language and raises LanguageChanged after a language change.
- Provides English fallback when a language or key is missing.
- Localizes compatible configuration labels in HowToFish.ModMenu and HTFModManager.
For Players
This mod is an API/dependency. It does not add gameplay features by itself.
Install it when another How to Fish mod lists How to Fish Localization API as a requirement.
The configuration-label integration is optional. Mods that do not register localization data are left unchanged.
For Mod Authors
Reference HowtoFishLocalizationAPI.dll and add a hard BepInEx dependency:
using System.IO;
using System.Reflection;
using BepInEx;
using HowtoFishLocalizationAPI.Api;
[BepInPlugin(PluginInfo.PLUGIN_GUID, "My Mod", "1.0.0")]
[BepInDependency(HowtoFishLocalizationAPI.PluginInfo.PLUGIN_GUID)]
public sealed class MyPlugin: BaseUnityPlugin
{
private ModLocalizer _localizer;
private void Awake()
{
string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
_localizer = LocalizationApi.For(PluginInfo.PLUGIN_GUID);
_localizer.RegisterJson(Path.Combine(directory, "MyMod.Localization.json"));
LocalizationApi.LanguageChanged += OnLanguageChanged;
}
private void OnLanguageChanged(string language)
{
// Refresh this mod's existing UI text here.
}
}
Load the JSON file from the directory containing your mod DLL. This also works with generated mod-manager folder names:
using System.IO;
using System.Reflection;
using HowtoFishLocalizationAPI.Api;
internal static class I18n
{
private const string FileName = "MyMod.Localization.json";
private static readonly ModLocalizer Localizer = Load();
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;
}
}
Use I18n.Text("your.key") for mod UI text. The args parameters are optional and use standard string.Format placeholders.
Configuration Labels
Compatible configuration managers use the following key format:
modmenu.config..
For example, a Controls / OpenWallet entry uses modmenu.config.Controls.OpenWallet. The label is applied when the configuration row is created, and missing keys keep the original configuration label.
Example localization file:
{
"en": {
"mod.name": "My Mod",
"mod.description": "A short description of my mod.",
"modmenu.config.General.Enabled": "General / Enabled"
},
"zh-CN": {
"mod.name": "我的模組",
"mod.description": "我的模組簡介。",
"modmenu.config.General.Enabled": "常規 / 啓用"
}
}
Every localization file must contain an en object. If the current language or requested key is missing, the API tries en; if the key is still missing, it returns the key itself.
Supported Language Codes
- English: en
- Swedish: sv
- Simplified Chinese: zh-CN
- Traditional Chinese: zh-TW
- French: fr
- German: de
- Italian: it
- Japanese: ja
- Korean: ko
- Polish: pl
- Brazilian Portuguese: pt-BR
- Russian: ru
- Latin American Spanish: es-MX
- European Spanish: es-ES
- Turkish: tr
- Ukrainian: uk
Compatibility
- Game: How to Fish 1.0.4+
- ModMenu: 0.3.3+
- HFModManager: 1.0.1
Bug Reports & Feature Suggestions
If you have any questions or feature suggestions, please submit them through GitHub Issues, contact me on Discord at iceboxcool, or email 764884112@qq.com
安裝與使用 安裝:按包內說明操作
- 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
- 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
- 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
- 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。
不同模組的安裝位置差異較大,包內說明是最可靠的依據。
下面這些內容需要先安裝,否則該模組不會生效: