Files
XplorePlane/XP.Camera/LocalizationHelper.cs
T
2026-05-11 10:11:50 +08:00

43 lines
980 B
C#

using System.Globalization;
using System.Resources;
namespace XP.Camera;
/// <summary>
/// 本地化辅助类
/// 使用 XP.Common 的资源文件
/// </summary>
public static class LocalizationHelper
{
private static ResourceManager? _resourceManager;
private static ResourceManager ResourceManager
{
get
{
if (_resourceManager == null)
{
_resourceManager = new ResourceManager(
"XP.Common.Resources.Resources",
typeof(XP.Common.Resources.Resources).Assembly);
}
return _resourceManager;
}
}
/// <summary>
/// 获取本地化字符串
/// </summary>
public static string GetString(string key)
{
try
{
var value = ResourceManager.GetString(key, CultureInfo.CurrentUICulture);
return value ?? key;
}
catch
{
return key;
}
}
}