Skip to content

Commit edec9ce

Browse files
committed
optmize readme
1 parent ba82a55 commit edec9ce

2 files changed

Lines changed: 27 additions & 12 deletions

File tree

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ AotSettingRegistry.Accessor = AotSettingRegistry.Provider;
156156

157157
## Internationalization (i18n)
158158

159-
AutoSettingUI supports dynamic language switching powered by [DynamicLocalization](https://github.com/StarryXYJ/Avalonia.DynamicLocalization).
159+
AutoSettingUI supports dynamic language switching powered by [DynamicLocalization](https://github.com/StarryXYJ/DynamicLocalization).
160160

161161
### Using Resource Keys
162162

@@ -233,12 +233,15 @@ public class MainViewModel
233233

234234
### Localization Providers
235235

236+
DynamicLocalization supports multiple data sources for translations:
237+
236238
| Provider | Description |
237239
|----------|-------------|
238240
| `ResxLocalizationProvider` | Uses .NET .resx resource files |
239241
| `JsonLocalizationProvider` | JSON file-based translations |
242+
| Custom Provider | Implement `ILocalizationProvider` for database, API, etc. |
240243

241-
For more providers and advanced usage, see [DynamicLocalization](https://github.com/StarryXYJ/Avalonia.DynamicLocalization).
244+
For more providers and advanced usage, see [DynamicLocalization](https://github.com/StarryXYJ/DynamicLocalization).
242245

243246
## Available Attributes
244247

README.zh-CN.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ AotSettingRegistry.Accessor = AotSettingRegistry.Provider;
156156

157157
## 国际化(i18n)
158158

159-
AutoSettingUI 通过 `ILocalizationService` 接口支持动态语言切换
159+
AutoSettingUI 通过 [DynamicLocalization](https://github.com/StarryXYJ/DynamicLocalization) 支持动态语言切换
160160

161161
### 使用资源键
162162

@@ -199,16 +199,23 @@ public static class Strings
199199
**3. 配置本地化服务:**
200200

201201
```csharp
202-
using AutoSettingUI.Core.Interfaces;
203-
using AutoSettingUI.Core.Services;
202+
using DynamicLocalization.Core;
203+
using DynamicLocalization.Core.Providers;
204204

205205
public class MainViewModel
206206
{
207-
public ILocalizationService LocalizationService { get; }
207+
public ICultureService LocalizationService { get; }
208208

209209
public MainViewModel()
210210
{
211-
LocalizationService = new ResxLocalizationService(Strings.ResourceManager);
211+
var cultureService = new CultureService();
212+
var resxProvider = new ResxLocalizationProvider();
213+
resxProvider.Initialize(new ResxLocalizationProviderOptions
214+
{
215+
ResourceType = typeof(Strings)
216+
});
217+
cultureService.RegisterProvider(resxProvider);
218+
LocalizationService = cultureService;
212219
}
213220

214221
public void SwitchToEnglish() => LocalizationService.SetCulture("en");
@@ -224,12 +231,17 @@ public class MainViewModel
224231
LocalizationService="{Binding LocalizationService}" />
225232
```
226233

227-
### 本地化服务
234+
### 本地化数据源
228235

229-
| 服务 | 说明 |
230-
|------|------|
231-
| `ResxLocalizationService` | 使用 .NET .resx 资源文件 |
232-
| `DictionaryLocalizationService` | 基于内存字典的翻译 |
236+
DynamicLocalization 支持多种翻译数据源:
237+
238+
| 提供者 | 说明 |
239+
|--------|------|
240+
| `ResxLocalizationProvider` | 使用 .NET .resx 资源文件 |
241+
| `JsonLocalizationProvider` | 基于 JSON 文件的翻译 |
242+
| 自定义提供者 | 实现 `ILocalizationProvider` 接口,支持数据库、API 等 |
243+
244+
更多数据源和高级用法,请参阅 [DynamicLocalization](https://github.com/StarryXYJ/DynamicLocalization)
233245

234246
## 可用特性一览
235247

0 commit comments

Comments
 (0)