ShiftAtMidnightLocalizationAPI
Shift At Midnight Localization API is a simple API module that enables mods to support multiple languages.
模組介紹 作者原文
Note: This description is bilingual. The Chinese section is provided below the English section.
說明:本描述爲中英雙語版本,中文內容位於英文內容下方。
Shift At Midnight Localization API (English)
Shift At Midnight Localization API is a simple API module that enables mods to support multiple languages.
What This Mod Does
- Provides language support for compatible mods.
- Updates supported mod text after the game language changes.
For Players
This mod is an API/dependency. It does not add gameplay features by itself.
Install it if another mod lists Shift At Midnight Localization API as a requirement.
For Mod Authors
Reference ShiftAtMidnightLocalizationAPI.dll and add a hard BepInEx dependency:
using BepInEx;
using BepInEx.Unity.IL2CPP;
using ShiftAtMidnightLocalizationAPI.Api;
[BepInDependency(ShiftAtMidnightLocalizationAPI.PluginInfo.PLUGIN_GUID)]
public sealed class MyPlugin: BasePlugin
{
public override void Load()
{
var enabled = Config.Bind("General", "Enabled", true, I18n.Text("config.enabled"));
I18n.RegisterDescription(enabled, "config.enabled");
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 also works with generated r2modman and mod-manager folder names:
using System.IO;
using System.Reflection;
using BepInEx.Configuration;
using ShiftAtMidnightLocalizationAPI.Api;
internal static class I18n
{
private const string FileName = "MyMod.Localization.json";
private static readonly ModLocalizer Localizer = Load();
public static string Text(string key, params object args)
{
return Localizer.GetLocalizedText(key, args);
}
public static void RegisterDescription(ConfigEntryBase entry, string key)
{
Localizer.RegisterConfigDescription(entry, key);
}
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;
}
}
Single JSON file example:
{
"ENGLISH": {
"mod.name": "My Mod",
"config.enabled": "Enable this mod."
},
"SIMPLIFIED CHINESE": {
"mod.name": "我的模組",
"config.enabled": "啓用這個模組。"
}
}
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
- Russian: RUSSIAN
- German: GERMAN
- Spanish: SPANISH
- Japanese: JAPANESE
- Simplified Chinese: SIMPLIFIED CHINESE
- Traditional Chinese: TRADITIONAL CHINESE
- Brazilian Portuguese: BR PORTUGESE
Compatibility
- Game version: 1.0.1.0723.2253+
Installation
- Download and install BepInEx be.785 Unity (IL2CPP) for Windows (x64) games.
- Extract the mod into the game's root folder. The archive already includes the BepInEx\plugins folder structure.
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 me at 764884112@qq.com or ibox2333@gmail.com.
If you enjoy my mods, buy me a coffee! / 如果你喜歡我的模組,請我喝一杯咖啡吧!
Shift At Midnight Localization API (中文)
Shift At Midnight Localization API 是一個簡單的 API 模組,用於讓模組支持多語言。
主要功能
- 爲兼容的模組提供多語言支持。
- 切換遊戲語言後更新受支持模組的文本。
給玩家
這是一個 API/依賴模組,本身不會添加玩法內容。
如果其他模組要求安裝 Shift At Midnight Localization API,請安裝它。
給模組作者
在項目中引用 ShiftAtMidnightLocalizationAPI.dll,並添加 BepInEx 硬依賴:
using BepInEx;
using BepInEx.Unity.IL2CPP;
using ShiftAtMidnightLocalizationAPI.Api;
[BepInDependency(ShiftAtMidnightLocalizationAPI.PluginInfo.PLUGIN_GUID)]
public sealed class MyPlugin: BasePlugin
{
public override void Load()
{
var enabled = Config.Bind("General", "Enabled", true, I18n.Text("config.enabled"));
I18n.RegisterDescription(enabled, "config.enabled");
Localizat
安裝與使用 安裝:按包內說明操作
- 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
- 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
- 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
- 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。
不同模組的安裝位置差異較大,包內說明是最可靠的依據。
下面這些內容需要先安裝,否則該模組不會生效: