69 lines
2.9 KiB
C#
69 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Resources;
|
|
using XP.Common.Localization.Enums;
|
|
using XP.Common.Localization.Events;
|
|
|
|
namespace XP.Common.Localization.Interfaces
|
|
{
|
|
/// <summary>
|
|
/// 本地化服务接口 | Localization service interface
|
|
/// 提供多语言资源访问和语言切换功能 | Provides multilingual resource access and language switching
|
|
/// </summary>
|
|
public interface ILocalizationService
|
|
{
|
|
/// <summary>
|
|
/// 获取当前语言 | Get current language
|
|
/// </summary>
|
|
SupportedLanguage CurrentLanguage { get; }
|
|
|
|
/// <summary>
|
|
/// 语言切换事件 | Language changed event
|
|
/// </summary>
|
|
event EventHandler<LanguageChangedEventArgs> LanguageChanged;
|
|
|
|
/// <summary>
|
|
/// 获取本地化字符串(使用当前语言)| Get localized string (using current language)
|
|
/// </summary>
|
|
/// <param name="key">资源键 | Resource key</param>
|
|
/// <returns>本地化字符串 | Localized string</returns>
|
|
string GetString(string key);
|
|
|
|
/// <summary>
|
|
/// 获取本地化字符串(指定语言)| Get localized string (specified language)
|
|
/// </summary>
|
|
/// <param name="key">资源键 | Resource key</param>
|
|
/// <param name="culture">文化信息 | Culture info</param>
|
|
/// <returns>本地化字符串 | Localized string</returns>
|
|
string GetString(string key, CultureInfo culture);
|
|
|
|
/// <summary>
|
|
/// 设置当前语言 | Set current language
|
|
/// </summary>
|
|
/// <param name="language">目标语言 | Target language</param>
|
|
void SetLanguage(SupportedLanguage language);
|
|
|
|
/// <summary>
|
|
/// 获取所有支持的语言 | Get all supported languages
|
|
/// </summary>
|
|
/// <returns>支持的语言列表 | List of supported languages</returns>
|
|
IEnumerable<SupportedLanguage> GetSupportedLanguages();
|
|
|
|
/// <summary>
|
|
/// 注册模块资源源到 Fallback Chain 末尾(最高优先级)
|
|
/// Register a module resource source to the end of the Fallback Chain (highest priority)
|
|
/// </summary>
|
|
/// <param name="name">资源源名称(如 "XP.Scan"),用于标识和注销 | Resource source name (e.g. "XP.Scan"), used for identification and unregistration</param>
|
|
/// <param name="resourceManager">模块的 ResourceManager 实例 | The module's ResourceManager instance</param>
|
|
void RegisterResourceSource(string name, ResourceManager resourceManager);
|
|
|
|
/// <summary>
|
|
/// 从 Fallback Chain 中注销指定资源源
|
|
/// Unregister the specified resource source from the Fallback Chain
|
|
/// </summary>
|
|
/// <param name="name">资源源名称 | Resource source name</param>
|
|
void UnregisterResourceSource(string name);
|
|
}
|
|
}
|