using System.Globalization;
using System.Resources;
namespace XP.Camera;
///
/// 本地化辅助类
/// 使用 XP.Common 的资源文件
///
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;
}
}
///
/// 获取本地化字符串
///
public static string GetString(string key)
{
try
{
var value = ResourceManager.GetString(key, CultureInfo.CurrentUICulture);
return value ?? key;
}
catch
{
return key;
}
}
}