Files
zeling_v2/Assets/_Game/Scripts/Localization/LocalizationPaths.cs
2026-06-06 09:00:11 +08:00

41 lines
2.0 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.
namespace BaseGames.Localization
{
/// <summary>
/// 本地化资源路径 / Addressable 地址的唯一真相源。
///
/// 运行时与编辑器工具的所有路径、地址都必须经此类构造,禁止再硬编码
/// "Assets/_Game/Data/Localization" 或 "Localization/{lang}/{table}" 字符串。
///
/// 设计要点:
/// - 纯静态、无 UnityEditor 依赖,放运行时 asmdef<c>BaseGames.Localization</c>
/// 使运行时加载(<see cref="LocalizationManager"/>)与编辑器工具共用同一套路径逻辑。
/// - 物理 JSON 路径(<see cref="AssetPath"/>)供编辑器直读 / 写盘;
/// Addressable 地址(<see cref="Address"/>)供运行时 <c>AssetLoader</c> 加载。
/// </summary>
public static class LocalizationPaths
{
/// <summary>本地化 JSON 数据根目录(项目资产相对路径)。</summary>
public const string DataRoot = "Assets/_Game/Data/Localization";
/// <summary>CSV 导入导出目录(供 Excel 往返)。</summary>
public const string ExportRoot = "Assets/_Game/Localization/Export";
/// <summary>指定语言的子目录,如 <c>Assets/_Game/Data/Localization/English</c>。</summary>
public static string LanguageFolder(Language language) => $"{DataRoot}/{language}";
/// <summary>指定语言 + 表的 JSON 资产路径。</summary>
public static string AssetPath(Language language, string table)
=> $"{DataRoot}/{language}/{table}.json";
/// <summary>
/// 指定语言 + 表的 Addressable 地址(运行时加载用)。
/// 必须与 <see cref="AssetPath"/> 指向的文件注册的地址一致。
/// </summary>
public static string Address(Language language, string table)
=> $"Localization/{language}/{table}";
/// <summary>指定表的 CSV 导出路径。</summary>
public static string CsvPath(string table) => $"{ExportRoot}/{table}.csv";
}
}