Files
zeling_v2/Assets/_Game/Scripts/Localization/ILocalizableAsset.cs
2026-05-25 11:54:37 +08:00

43 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections.Generic;
namespace BaseGames.Localization
{
/// <summary>
/// 标记一个 ScriptableObject 持有可本地化字段。
/// 实现此接口后,<see cref="BaseGames.Editor.Modules.LocalizationAuditModule"/>
/// 将自动发现并检查该 SO 的所有 Key无需在审计模块中硬编码扫描逻辑。
///
/// 新增 SO 类型时:实现此接口即可自动纳入本地化审计,不需要修改审计模块。
/// </summary>
public interface ILocalizableAsset
{
/// <summary>
/// 返回该资产中所有本地化 Key 的引用列表。
/// 实现时跳过空 key<c>string.IsNullOrEmpty</c> 检查)。
/// </summary>
IEnumerable<LocalizationKeyRef> GetLocalizationKeys();
}
/// <summary>
/// 对一个本地化 Key 引用的描述,供审计工具使用。
/// </summary>
public readonly struct LocalizationKeyRef
{
/// <summary>本地化 Key 字符串。</summary>
public readonly string Key;
/// <summary>所属表名(使用 <see cref="LocalizationTable"/> 常量)。</summary>
public readonly string Table;
/// <summary>该 Key 来自的字段名称,用于审计报告中精确定位。</summary>
public readonly string FieldName;
public LocalizationKeyRef(string key, string table, string fieldName)
{
Key = key;
Table = table;
FieldName = fieldName;
}
}
}