ShiftAtMidnightLocalizationAPI
Shift At Midnight Localization API is a simple API module that enables mods to support multiple languages.
| Date uploaded | 2 days ago |
| Version | 1.0.0 |
| Download link | Ice_Box_Studio_SAM-ShiftAtMidnightLocalizationAPI-1.0.0.zip |
| Downloads | 168 |
| Dependency string | Ice_Box_Studio_SAM-ShiftAtMidnightLocalizationAPI-1.0.0 |
This mod requires the following mods to function
BepInEx-BepInExPack_IL2CPP
BepInEx pack for IL2CPP x64 Unity games. Preconfigured and ready to use.
Preferred version: 6.0.755README
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\pluginsfolder 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 [email protected] or [email protected].
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");
LocalizationApi.LanguageChanged += OnLanguageChanged;
}
private static void OnLanguageChanged(string language)
{
// 在这里刷新模组已经创建的 UI 文本。
}
}
从模组 DLL 自己所在的目录加载 JSON。这样即使 r2modman 或其他模组管理器生成了不同的插件文件夹名,也能正确找到语言文件:
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;
}
}
单 JSON 文件示例:
{
"ENGLISH": {
"mod.name": "My Mod",
"config.enabled": "Enable this mod."
},
"SIMPLIFIED CHINESE": {
"mod.name": "我的模组",
"config.enabled": "启用这个模组。"
}
}
每个语言文件都必须包含 ENGLISH 对象。当前语言或目标 key 缺失时,API 会尝试 ENGLISH;如果英语中仍缺少该 key,则直接返回 key 本身。
支持的语言名
- 英语:
ENGLISH - 法语:
FRENCH - 俄语:
RUSSIAN - 德语:
GERMAN - 西班牙语:
SPANISH - 日语:
JAPANESE - 简体中文:
SIMPLIFIED CHINESE - 繁体中文:
TRADITIONAL CHINESE - 巴西葡萄牙语:
BR PORTUGESE
兼容性
- 游戏版本:
1.0.1.0723.2253+
安装方法
- 下载并安装 BepInEx be.785 Unity (IL2CPP) for Windows (x64) games。
- 将模组解压到游戏根目录即可,压缩包内已包含
BepInEx\plugins路径。
Bug 提交 & 新功能建议
如果你有任何问题或新功能建议,请通过 GitHub Issues 提交,也可以通过 Discord:iceboxcool,或邮箱 [email protected]、[email protected] 联系我。
CHANGELOG
v1.0.0
中文
- 初始发布
English
- Initial release