14 changed files with 1427 additions and 126 deletions
@ -0,0 +1,137 @@ |
|||||
|
# LINGYUN.Abp.Location.Baidu |
||||
|
|
||||
|
## Introduction |
||||
|
|
||||
|
`LINGYUN.Abp.Location.Baidu` is a location service implementation module based on Baidu Maps API, providing functionalities such as geocoding, reverse geocoding, IP location, and more. |
||||
|
|
||||
|
## Features |
||||
|
|
||||
|
* Geocoding: Convert structured addresses into latitude and longitude coordinates |
||||
|
* Reverse Geocoding: Convert coordinates into structured addresses |
||||
|
* IP Location: Get location information based on IP addresses |
||||
|
* POI (Points of Interest) Information: Get information about nearby businesses, restaurants, and other points of interest |
||||
|
* Road Information: Get information about nearby roads |
||||
|
* Administrative Region Information: Get detailed administrative region hierarchy information |
||||
|
|
||||
|
## Installation |
||||
|
|
||||
|
```bash |
||||
|
dotnet add package LINGYUN.Abp.Location.Baidu |
||||
|
``` |
||||
|
|
||||
|
## Configuration |
||||
|
|
||||
|
1. Add module dependency: |
||||
|
|
||||
|
```csharp |
||||
|
[DependsOn(typeof(AbpBaiduLocationModule))] |
||||
|
public class YourModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<BaiduLocationOptions>(options => |
||||
|
{ |
||||
|
// Set Baidu Maps API key |
||||
|
options.AccessKey = "your-baidu-map-ak"; |
||||
|
// Optional: Set security key (for sn verification) |
||||
|
options.SecurityKey = "your-baidu-map-sk"; |
||||
|
// Optional: Set coordinate system type (default is bd09ll) |
||||
|
options.CoordType = "bd09ll"; |
||||
|
// Optional: Set output format (default is json) |
||||
|
options.Output = "json"; |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## Usage |
||||
|
|
||||
|
1. Inject and use the location resolution service: |
||||
|
|
||||
|
```csharp |
||||
|
public class YourLocationService |
||||
|
{ |
||||
|
private readonly ILocationResolveProvider _locationProvider; |
||||
|
|
||||
|
public YourLocationService(ILocationResolveProvider locationProvider) |
||||
|
{ |
||||
|
_locationProvider = locationProvider; |
||||
|
} |
||||
|
|
||||
|
// Geocoding: Convert address to coordinates |
||||
|
public async Task<GecodeLocation> GeocodeAsync(string address) |
||||
|
{ |
||||
|
// city parameter is optional, used to specify the city of the address |
||||
|
return await _locationProvider.GeocodeAsync(address, "Beijing"); |
||||
|
} |
||||
|
|
||||
|
// Reverse Geocoding: Convert coordinates to address |
||||
|
public async Task<ReGeocodeLocation> ReGeocodeAsync(double lat, double lng) |
||||
|
{ |
||||
|
// radius parameter is optional, specifies search radius (in meters) |
||||
|
return await _locationProvider.ReGeocodeAsync(lat, lng, 1000); |
||||
|
} |
||||
|
|
||||
|
// IP Geolocation |
||||
|
public async Task<IPGecodeLocation> IPGeocodeAsync(string ipAddress) |
||||
|
{ |
||||
|
return await _locationProvider.IPGeocodeAsync(ipAddress); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## Response Data Description |
||||
|
|
||||
|
### Geocoding Response Data |
||||
|
|
||||
|
```json |
||||
|
{ |
||||
|
"location": { |
||||
|
"lat": 39.915119, // Latitude value |
||||
|
"lng": 116.403963 // Longitude value |
||||
|
}, |
||||
|
"precise": 1, // Additional location info, precise match or not (1 for precise, 0 for not precise) |
||||
|
"confidence": 80, // Confidence level |
||||
|
"comprehension": 100, // Address understanding level |
||||
|
"level": "门址" // Address type |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### Reverse Geocoding Response Data |
||||
|
|
||||
|
```json |
||||
|
{ |
||||
|
"location": { |
||||
|
"lat": 39.915119, // Latitude value |
||||
|
"lng": 116.403963 // Longitude value |
||||
|
}, |
||||
|
"formatted_address": "Dongchangan Street, Dongcheng District, Beijing", // Structured address |
||||
|
"business": "Tiananmen", // Business area information |
||||
|
"addressComponent": { |
||||
|
"country": "China", // Country |
||||
|
"province": "Beijing", // Province |
||||
|
"city": "Beijing", // City |
||||
|
"district": "Dongcheng District", // District |
||||
|
"street": "Dongchangan Street", // Street |
||||
|
"street_number": "1" // Street number |
||||
|
}, |
||||
|
"pois": [ // Nearby POIs |
||||
|
{ |
||||
|
"name": "Tiananmen", // POI name |
||||
|
"type": "Tourist Attraction", // POI type |
||||
|
"distance": "100" // Distance (meters) |
||||
|
} |
||||
|
], |
||||
|
"roads": [ // Nearby roads |
||||
|
{ |
||||
|
"name": "Dongchangan Street", // Road name |
||||
|
"distance": "50" // Distance (meters) |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## More Information |
||||
|
|
||||
|
* [中文文档](./README.md) |
||||
|
* [Baidu Maps Open Platform](https://lbsyun.baidu.com/) |
||||
@ -0,0 +1,137 @@ |
|||||
|
# LINGYUN.Abp.Location.Baidu |
||||
|
|
||||
|
## 介绍 |
||||
|
|
||||
|
`LINGYUN.Abp.Location.Baidu` 是基于百度地图API的位置服务实现模块,提供了地理编码、反向地理编码、IP定位等功能。 |
||||
|
|
||||
|
## 功能特性 |
||||
|
|
||||
|
* 地理编码:将详细的结构化地址转换为对应的经纬度坐标 |
||||
|
* 反向地理编码:将经纬度坐标转换为对应的结构化地址 |
||||
|
* IP定位:根据IP地址获取位置信息 |
||||
|
* POI(兴趣点)信息:获取周边的商铺、餐厅等兴趣点信息 |
||||
|
* 道路信息:获取附近的道路信息 |
||||
|
* 行政区划信息:获取详细的行政区划层级信息 |
||||
|
|
||||
|
## 安装 |
||||
|
|
||||
|
```bash |
||||
|
dotnet add package LINGYUN.Abp.Location.Baidu |
||||
|
``` |
||||
|
|
||||
|
## 配置 |
||||
|
|
||||
|
1. 添加模块依赖: |
||||
|
|
||||
|
```csharp |
||||
|
[DependsOn(typeof(AbpBaiduLocationModule))] |
||||
|
public class YourModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<BaiduLocationOptions>(options => |
||||
|
{ |
||||
|
// 设置百度地图API密钥 |
||||
|
options.AccessKey = "your-baidu-map-ak"; |
||||
|
// 可选:设置安全密钥(sn校验) |
||||
|
options.SecurityKey = "your-baidu-map-sk"; |
||||
|
// 可选:设置坐标系类型(默认为bd09ll) |
||||
|
options.CoordType = "bd09ll"; |
||||
|
// 可选:设置输出格式(默认为json) |
||||
|
options.Output = "json"; |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## 使用方法 |
||||
|
|
||||
|
1. 注入并使用位置解析服务: |
||||
|
|
||||
|
```csharp |
||||
|
public class YourLocationService |
||||
|
{ |
||||
|
private readonly ILocationResolveProvider _locationProvider; |
||||
|
|
||||
|
public YourLocationService(ILocationResolveProvider locationProvider) |
||||
|
{ |
||||
|
_locationProvider = locationProvider; |
||||
|
} |
||||
|
|
||||
|
// 地理编码:地址转坐标 |
||||
|
public async Task<GecodeLocation> GeocodeAsync(string address) |
||||
|
{ |
||||
|
// city参数可选,用于指定地址所在城市 |
||||
|
return await _locationProvider.GeocodeAsync(address, "北京市"); |
||||
|
} |
||||
|
|
||||
|
// 反向地理编码:坐标转地址 |
||||
|
public async Task<ReGeocodeLocation> ReGeocodeAsync(double lat, double lng) |
||||
|
{ |
||||
|
// radius参数可选,指定搜索半径(米) |
||||
|
return await _locationProvider.ReGeocodeAsync(lat, lng, 1000); |
||||
|
} |
||||
|
|
||||
|
// IP地理位置解析 |
||||
|
public async Task<IPGecodeLocation> IPGeocodeAsync(string ipAddress) |
||||
|
{ |
||||
|
return await _locationProvider.IPGeocodeAsync(ipAddress); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## 返回数据说明 |
||||
|
|
||||
|
### 地理编码返回数据 |
||||
|
|
||||
|
```json |
||||
|
{ |
||||
|
"location": { |
||||
|
"lat": 39.915119, // 纬度值 |
||||
|
"lng": 116.403963 // 经度值 |
||||
|
}, |
||||
|
"precise": 1, // 位置的附加信息,是否精确查找(1为精确,0为不精确) |
||||
|
"confidence": 80, // 可信度 |
||||
|
"comprehension": 100, // 地址理解程度 |
||||
|
"level": "门址" // 地址类型 |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### 反向地理编码返回数据 |
||||
|
|
||||
|
```json |
||||
|
{ |
||||
|
"location": { |
||||
|
"lat": 39.915119, // 纬度值 |
||||
|
"lng": 116.403963 // 经度值 |
||||
|
}, |
||||
|
"formatted_address": "北京市东城区东长安街", // 结构化地址信息 |
||||
|
"business": "天安门", // 商圈信息 |
||||
|
"addressComponent": { |
||||
|
"country": "中国", // 国家 |
||||
|
"province": "北京市", // 省份 |
||||
|
"city": "北京市", // 城市 |
||||
|
"district": "东城区", // 区县 |
||||
|
"street": "东长安街", // 街道 |
||||
|
"street_number": "1号" // 门牌号 |
||||
|
}, |
||||
|
"pois": [ // 周边POI信息 |
||||
|
{ |
||||
|
"name": "天安门", // POI名称 |
||||
|
"type": "旅游景点", // POI类型 |
||||
|
"distance": "100" // 距离(米) |
||||
|
} |
||||
|
], |
||||
|
"roads": [ // 周边道路信息 |
||||
|
{ |
||||
|
"name": "东长安街", // 道路名称 |
||||
|
"distance": "50" // 距离(米) |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## 更多信息 |
||||
|
|
||||
|
* [English Documentation](./README.EN.md) |
||||
|
* [百度地图开放平台](https://lbsyun.baidu.com/) |
||||
@ -0,0 +1,144 @@ |
|||||
|
# LINGYUN.Abp.Location.Tencent |
||||
|
|
||||
|
## Introduction |
||||
|
|
||||
|
`LINGYUN.Abp.Location.Tencent` is a location service implementation module based on Tencent Maps API, providing functionalities such as geocoding, reverse geocoding, IP location, and more. |
||||
|
|
||||
|
## Features |
||||
|
|
||||
|
* Geocoding: Convert structured addresses into latitude and longitude coordinates |
||||
|
* Reverse Geocoding: Convert coordinates into structured addresses |
||||
|
* IP Location: Get location information based on IP addresses |
||||
|
* POI (Points of Interest) Information: Get information about nearby businesses, restaurants, and other points of interest |
||||
|
* Administrative Region Information: Get detailed administrative region hierarchy information |
||||
|
* Address Parsing: Intelligent address parsing supporting multiple formats |
||||
|
|
||||
|
## Installation |
||||
|
|
||||
|
```bash |
||||
|
dotnet add package LINGYUN.Abp.Location.Tencent |
||||
|
``` |
||||
|
|
||||
|
## Configuration |
||||
|
|
||||
|
1. Add module dependency: |
||||
|
|
||||
|
```csharp |
||||
|
[DependsOn(typeof(AbpTencentLocationModule))] |
||||
|
public class YourModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<TencentLocationOptions>(options => |
||||
|
{ |
||||
|
// Set Tencent Maps API key |
||||
|
options.Key = "your-tencent-map-key"; |
||||
|
// Optional: Set security key (for SK verification) |
||||
|
options.SecretKey = "your-tencent-map-sk"; |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## Usage |
||||
|
|
||||
|
1. Inject and use the location resolution service: |
||||
|
|
||||
|
```csharp |
||||
|
public class YourLocationService |
||||
|
{ |
||||
|
private readonly ILocationResolveProvider _locationProvider; |
||||
|
|
||||
|
public YourLocationService(ILocationResolveProvider locationProvider) |
||||
|
{ |
||||
|
_locationProvider = locationProvider; |
||||
|
} |
||||
|
|
||||
|
// Geocoding: Convert address to coordinates |
||||
|
public async Task<GecodeLocation> GeocodeAsync(string address) |
||||
|
{ |
||||
|
// city parameter is optional, used to specify the city of the address |
||||
|
return await _locationProvider.GeocodeAsync(address, "Beijing"); |
||||
|
} |
||||
|
|
||||
|
// Reverse Geocoding: Convert coordinates to address |
||||
|
public async Task<ReGeocodeLocation> ReGeocodeAsync(double lat, double lng) |
||||
|
{ |
||||
|
// radius parameter is optional, specifies search radius (in meters) |
||||
|
return await _locationProvider.ReGeocodeAsync(lat, lng, 1000); |
||||
|
} |
||||
|
|
||||
|
// IP Geolocation |
||||
|
public async Task<IPGecodeLocation> IPGeocodeAsync(string ipAddress) |
||||
|
{ |
||||
|
return await _locationProvider.IPGeocodeAsync(ipAddress); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## Response Data Description |
||||
|
|
||||
|
### Geocoding Response Data |
||||
|
|
||||
|
```json |
||||
|
{ |
||||
|
"location": { |
||||
|
"lat": 39.915119, // Latitude value |
||||
|
"lng": 116.403963 // Longitude value |
||||
|
}, |
||||
|
"title": "Tiananmen", // Place name |
||||
|
"address": "Dongchangan Street, Dongcheng District, Beijing", // Address |
||||
|
"category": "Tourist Attraction", // Category |
||||
|
"adcode": "110101", // Administrative region code |
||||
|
"similarity": 0.8, // Similarity (0-1) |
||||
|
"reliability": 7, // Reliability (1-10) |
||||
|
"level": 11 // Address type |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### Reverse Geocoding Response Data |
||||
|
|
||||
|
```json |
||||
|
{ |
||||
|
"location": { |
||||
|
"lat": 39.915119, // Latitude value |
||||
|
"lng": 116.403963 // Longitude value |
||||
|
}, |
||||
|
"address": "Dongchangan Street, Dongcheng District, Beijing", // Complete address |
||||
|
"formatted_addresses": { |
||||
|
"recommend": "Tiananmen, Dongcheng District", // Recommended address |
||||
|
"rough": "Dongcheng District, Beijing" // Rough address |
||||
|
}, |
||||
|
"address_component": { |
||||
|
"nation": "China", // Country |
||||
|
"province": "Beijing", // Province |
||||
|
"city": "Beijing", // City |
||||
|
"district": "Dongcheng District", // District |
||||
|
"street": "Dongchangan Street", // Street |
||||
|
"street_number": "1" // Street number |
||||
|
}, |
||||
|
"pois": [ // Nearby POIs |
||||
|
{ |
||||
|
"title": "Tiananmen", // POI name |
||||
|
"address": "Dongchangan Street, Dongcheng District, Beijing", // POI address |
||||
|
"category": "Tourist Attraction", // POI type |
||||
|
"distance": 100, // Distance (meters) |
||||
|
"_distance": 100.0, // Distance (meters, float) |
||||
|
"tel": "", // Phone number |
||||
|
"ad_info": { // Administrative region info |
||||
|
"adcode": "110101", // Administrative region code |
||||
|
"name": "Dongcheng District", // Administrative region name |
||||
|
"location": { // Administrative region center point |
||||
|
"lat": 39.915119, |
||||
|
"lng": 116.403963 |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## More Information |
||||
|
|
||||
|
* [中文文档](./README.md) |
||||
|
* [Tencent Location Service](https://lbs.qq.com/) |
||||
@ -0,0 +1,144 @@ |
|||||
|
# LINGYUN.Abp.Location.Tencent |
||||
|
|
||||
|
## 介绍 |
||||
|
|
||||
|
`LINGYUN.Abp.Location.Tencent` 是基于腾讯地图API的位置服务实现模块,提供了地理编码、反向地理编码、IP定位等功能。 |
||||
|
|
||||
|
## 功能特性 |
||||
|
|
||||
|
* 地理编码:将详细的结构化地址转换为对应的经纬度坐标 |
||||
|
* 反向地理编码:将经纬度坐标转换为对应的结构化地址 |
||||
|
* IP定位:根据IP地址获取位置信息 |
||||
|
* POI(兴趣点)信息:获取周边的商铺、餐厅等兴趣点信息 |
||||
|
* 行政区划信息:获取详细的行政区划层级信息 |
||||
|
* 地址解析:智能解析地址信息,支持多种格式 |
||||
|
|
||||
|
## 安装 |
||||
|
|
||||
|
```bash |
||||
|
dotnet add package LINGYUN.Abp.Location.Tencent |
||||
|
``` |
||||
|
|
||||
|
## 配置 |
||||
|
|
||||
|
1. 添加模块依赖: |
||||
|
|
||||
|
```csharp |
||||
|
[DependsOn(typeof(AbpTencentLocationModule))] |
||||
|
public class YourModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<TencentLocationOptions>(options => |
||||
|
{ |
||||
|
// 设置腾讯地图API密钥 |
||||
|
options.Key = "your-tencent-map-key"; |
||||
|
// 可选:设置安全密钥(SK校验) |
||||
|
options.SecretKey = "your-tencent-map-sk"; |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## 使用方法 |
||||
|
|
||||
|
1. 注入并使用位置解析服务: |
||||
|
|
||||
|
```csharp |
||||
|
public class YourLocationService |
||||
|
{ |
||||
|
private readonly ILocationResolveProvider _locationProvider; |
||||
|
|
||||
|
public YourLocationService(ILocationResolveProvider locationProvider) |
||||
|
{ |
||||
|
_locationProvider = locationProvider; |
||||
|
} |
||||
|
|
||||
|
// 地理编码:地址转坐标 |
||||
|
public async Task<GecodeLocation> GeocodeAsync(string address) |
||||
|
{ |
||||
|
// city参数可选,用于指定地址所在城市 |
||||
|
return await _locationProvider.GeocodeAsync(address, "北京市"); |
||||
|
} |
||||
|
|
||||
|
// 反向地理编码:坐标转地址 |
||||
|
public async Task<ReGeocodeLocation> ReGeocodeAsync(double lat, double lng) |
||||
|
{ |
||||
|
// radius参数可选,指定搜索半径(米) |
||||
|
return await _locationProvider.ReGeocodeAsync(lat, lng, 1000); |
||||
|
} |
||||
|
|
||||
|
// IP地理位置解析 |
||||
|
public async Task<IPGecodeLocation> IPGeocodeAsync(string ipAddress) |
||||
|
{ |
||||
|
return await _locationProvider.IPGeocodeAsync(ipAddress); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## 返回数据说明 |
||||
|
|
||||
|
### 地理编码返回数据 |
||||
|
|
||||
|
```json |
||||
|
{ |
||||
|
"location": { |
||||
|
"lat": 39.915119, // 纬度值 |
||||
|
"lng": 116.403963 // 经度值 |
||||
|
}, |
||||
|
"title": "天安门", // 地点名称 |
||||
|
"address": "北京市东城区东长安街", // 地址 |
||||
|
"category": "旅游景点", // 类别 |
||||
|
"adcode": "110101", // 行政区划代码 |
||||
|
"similarity": 0.8, // 相似度(0-1) |
||||
|
"reliability": 7, // 可信度(1-10) |
||||
|
"level": 11 // 地址类型 |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### 反向地理编码返回数据 |
||||
|
|
||||
|
```json |
||||
|
{ |
||||
|
"location": { |
||||
|
"lat": 39.915119, // 纬度值 |
||||
|
"lng": 116.403963 // 经度值 |
||||
|
}, |
||||
|
"address": "北京市东城区东长安街", // 完整地址 |
||||
|
"formatted_addresses": { |
||||
|
"recommend": "东城区天安门", // 推荐地址 |
||||
|
"rough": "北京市东城区" // 粗略地址 |
||||
|
}, |
||||
|
"address_component": { |
||||
|
"nation": "中国", // 国家 |
||||
|
"province": "北京市", // 省份 |
||||
|
"city": "北京市", // 城市 |
||||
|
"district": "东城区", // 区县 |
||||
|
"street": "东长安街", // 街道 |
||||
|
"street_number": "1号" // 门牌号 |
||||
|
}, |
||||
|
"pois": [ // 周边POI信息 |
||||
|
{ |
||||
|
"title": "天安门", // POI名称 |
||||
|
"address": "北京市东城区东长安街", // POI地址 |
||||
|
"category": "旅游景点", // POI类型 |
||||
|
"distance": 100, // 距离(米) |
||||
|
"_distance": 100.0, // 距离(米,浮点数) |
||||
|
"tel": "", // 电话 |
||||
|
"ad_info": { // 行政区划信息 |
||||
|
"adcode": "110101", // 行政区划代码 |
||||
|
"name": "东城区", // 行政区划名称 |
||||
|
"location": { // 行政区划中心点 |
||||
|
"lat": 39.915119, |
||||
|
"lng": 116.403963 |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## 更多信息 |
||||
|
|
||||
|
* [English Documentation](./README.EN.md) |
||||
|
* [腾讯位置服务](https://lbs.qq.com/) |
||||
@ -0,0 +1,86 @@ |
|||||
|
# LINGYUN.Abp.AspNetCore.Mvc.Localization |
||||
|
|
||||
|
ABP framework localization management module, providing Web API interfaces for localization resources. |
||||
|
|
||||
|
## Features |
||||
|
|
||||
|
* Provides localization text management API interfaces |
||||
|
* Supports multi-language resource querying and comparison |
||||
|
* Supports filtering by resource name and culture name |
||||
|
* Supports integration of external localization resources |
||||
|
* Supports localization resource difference comparison |
||||
|
|
||||
|
## Installation |
||||
|
|
||||
|
```bash |
||||
|
dotnet add package LINGYUN.Abp.AspNetCore.Mvc.Localization |
||||
|
``` |
||||
|
|
||||
|
## Module Dependencies |
||||
|
|
||||
|
```csharp |
||||
|
[DependsOn(typeof(AbpAspNetCoreMvcLocalizationModule))] |
||||
|
public class YouProjectModule : AbpModule |
||||
|
{ |
||||
|
// other |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## API Endpoints |
||||
|
|
||||
|
### Language Management |
||||
|
|
||||
|
* GET /api/localization/languages - Get all available languages |
||||
|
* GET /api/localization/languages/{cultureName} - Get specific language information |
||||
|
|
||||
|
### Resource Management |
||||
|
|
||||
|
* GET /api/localization/resources - Get all localization resources |
||||
|
* GET /api/localization/resources/{name} - Get specific localization resource |
||||
|
|
||||
|
### Text Management |
||||
|
|
||||
|
* GET /api/localization/texts - Get localization text list |
||||
|
* GET /api/localization/texts/by-key - Get localization text by key |
||||
|
* GET /api/localization/texts/differences - Get text differences between languages |
||||
|
|
||||
|
## Basic Usage |
||||
|
|
||||
|
1. Configure localization resources |
||||
|
```csharp |
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Resources |
||||
|
.Get<YourLocalizationResource>() |
||||
|
.AddVirtualJson("/Your/Resource/Path"); |
||||
|
}); |
||||
|
``` |
||||
|
|
||||
|
2. Inject and use the service |
||||
|
```csharp |
||||
|
public class YourService |
||||
|
{ |
||||
|
private readonly ITextAppService _textAppService; |
||||
|
|
||||
|
public YourService(ITextAppService textAppService) |
||||
|
{ |
||||
|
_textAppService = textAppService; |
||||
|
} |
||||
|
|
||||
|
public async Task GetLocalizedText(string key, string cultureName) |
||||
|
{ |
||||
|
var text = await _textAppService.GetByCultureKeyAsync(new GetTextByKeyInput |
||||
|
{ |
||||
|
Key = key, |
||||
|
CultureName = cultureName, |
||||
|
ResourceName = "YourResourceName" |
||||
|
}); |
||||
|
// Use the localized text |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## More Information |
||||
|
|
||||
|
* [中文文档](./README.md) |
||||
|
* [ABP Localization Documentation](https://docs.abp.io/en/abp/latest/Localization) |
||||
@ -0,0 +1,86 @@ |
|||||
|
# LINGYUN.Abp.AspNetCore.Mvc.Localization |
||||
|
|
||||
|
ABP框架本地化管理模块,提供本地化资源的Web API接口。 |
||||
|
|
||||
|
## 功能特性 |
||||
|
|
||||
|
* 提供本地化文本管理API接口 |
||||
|
* 支持多语言资源的查询和比较 |
||||
|
* 支持按资源名称和文化名称过滤 |
||||
|
* 支持外部本地化资源的集成 |
||||
|
* 支持本地化资源的差异对比 |
||||
|
|
||||
|
## 安装 |
||||
|
|
||||
|
```bash |
||||
|
dotnet add package LINGYUN.Abp.AspNetCore.Mvc.Localization |
||||
|
``` |
||||
|
|
||||
|
## 模块依赖 |
||||
|
|
||||
|
```csharp |
||||
|
[DependsOn(typeof(AbpAspNetCoreMvcLocalizationModule))] |
||||
|
public class YouProjectModule : AbpModule |
||||
|
{ |
||||
|
// other |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## API接口 |
||||
|
|
||||
|
### 语言管理 |
||||
|
|
||||
|
* GET /api/localization/languages - 获取所有可用语言 |
||||
|
* GET /api/localization/languages/{cultureName} - 获取指定语言信息 |
||||
|
|
||||
|
### 资源管理 |
||||
|
|
||||
|
* GET /api/localization/resources - 获取所有本地化资源 |
||||
|
* GET /api/localization/resources/{name} - 获取指定本地化资源 |
||||
|
|
||||
|
### 文本管理 |
||||
|
|
||||
|
* GET /api/localization/texts - 获取本地化文本列表 |
||||
|
* GET /api/localization/texts/by-key - 根据键获取本地化文本 |
||||
|
* GET /api/localization/texts/differences - 获取不同语言间的文本差异 |
||||
|
|
||||
|
## 基本用法 |
||||
|
|
||||
|
1. 配置本地化资源 |
||||
|
```csharp |
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Resources |
||||
|
.Get<YourLocalizationResource>() |
||||
|
.AddVirtualJson("/Your/Resource/Path"); |
||||
|
}); |
||||
|
``` |
||||
|
|
||||
|
2. 注入并使用服务 |
||||
|
```csharp |
||||
|
public class YourService |
||||
|
{ |
||||
|
private readonly ITextAppService _textAppService; |
||||
|
|
||||
|
public YourService(ITextAppService textAppService) |
||||
|
{ |
||||
|
_textAppService = textAppService; |
||||
|
} |
||||
|
|
||||
|
public async Task GetLocalizedText(string key, string cultureName) |
||||
|
{ |
||||
|
var text = await _textAppService.GetByCultureKeyAsync(new GetTextByKeyInput |
||||
|
{ |
||||
|
Key = key, |
||||
|
CultureName = cultureName, |
||||
|
ResourceName = "YourResourceName" |
||||
|
}); |
||||
|
// Use the localized text |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## 更多信息 |
||||
|
|
||||
|
* [English Documentation](./README.EN.md) |
||||
|
* [ABP本地化文档](https://docs.abp.io/zh-Hans/abp/latest/Localization) |
||||
@ -0,0 +1,93 @@ |
|||||
|
# LINGYUN.Abp.Localization.CultureMap |
||||
|
|
||||
|
## Module Description |
||||
|
|
||||
|
This module solves localization issues with multiple culture format variants. It allows you to map different culture format identifiers to a standard format. |
||||
|
|
||||
|
Reference Project: [Owl.Abp.CultureMap](https://github.com/maliming/Owl.Abp.CultureMap) |
||||
|
|
||||
|
## Features |
||||
|
|
||||
|
* Support mapping multiple culture format identifiers to standard format |
||||
|
* Support independent mapping for Culture and UICulture |
||||
|
* Integration with ABP request localization |
||||
|
* Support custom culture mapping rules |
||||
|
|
||||
|
## Installation |
||||
|
|
||||
|
```bash |
||||
|
dotnet add package LINGYUN.Abp.Localization.CultureMap |
||||
|
``` |
||||
|
|
||||
|
## Base Modules |
||||
|
|
||||
|
* Volo.Abp.AspNetCore |
||||
|
|
||||
|
## Configuration |
||||
|
|
||||
|
The module provides the following configuration options: |
||||
|
|
||||
|
* CulturesMaps: List of culture mappings |
||||
|
* UiCulturesMaps: List of UI culture mappings |
||||
|
|
||||
|
Each mapping item contains: |
||||
|
* TargetCulture: Target culture identifier |
||||
|
* SourceCultures: List of source culture identifiers |
||||
|
|
||||
|
## Usage |
||||
|
|
||||
|
1. Add module dependency: |
||||
|
|
||||
|
```csharp |
||||
|
[DependsOn( |
||||
|
typeof(AbpLocalizationCultureMapModule))] |
||||
|
public class YouProjectModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<AbpLocalizationCultureMapOptions>(options => |
||||
|
{ |
||||
|
var zhHansCultureMapInfo = new CultureMapInfo |
||||
|
{ |
||||
|
TargetCulture = "zh-Hans", |
||||
|
SourceCultures = new string[] { "zh", "zh_CN", "zh-CN" } |
||||
|
}; |
||||
|
|
||||
|
options.CulturesMaps.Add(zhHansCultureMapInfo); |
||||
|
options.UiCulturesMaps.Add(zhHansCultureMapInfo); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
||||
|
{ |
||||
|
var app = context.GetApplicationBuilder(); |
||||
|
|
||||
|
app.UseMapRequestLocalization(); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## Common Use Cases |
||||
|
|
||||
|
1. Unify Simplified Chinese culture identifiers: |
||||
|
```csharp |
||||
|
options.CulturesMaps.Add(new CultureMapInfo |
||||
|
{ |
||||
|
TargetCulture = "zh-Hans", |
||||
|
SourceCultures = new string[] { "zh", "zh_CN", "zh-CN" } |
||||
|
}); |
||||
|
``` |
||||
|
|
||||
|
2. Unify Traditional Chinese culture identifiers: |
||||
|
```csharp |
||||
|
options.CulturesMaps.Add(new CultureMapInfo |
||||
|
{ |
||||
|
TargetCulture = "zh-Hant", |
||||
|
SourceCultures = new string[] { "zh_TW", "zh-TW", "zh_HK", "zh-HK" } |
||||
|
}); |
||||
|
``` |
||||
|
|
||||
|
## More Information |
||||
|
|
||||
|
* [中文文档](./README.md) |
||||
|
* [ABP Localization Documentation](https://docs.abp.io/en/abp/latest/Localization) |
||||
@ -0,0 +1,129 @@ |
|||||
|
# LINGYUN.Abp.Localization.Persistence |
||||
|
|
||||
|
## Module Description |
||||
|
|
||||
|
Localization component persistence module, providing functionality to persist localization resources to storage facilities. This module allows you to save static localization documents to persistent storage for easier management and maintenance. |
||||
|
|
||||
|
## Features |
||||
|
|
||||
|
* Support persisting static localization resources to storage facilities |
||||
|
* Provide read and write interfaces for localization resources |
||||
|
* Support custom persistence storage implementation |
||||
|
* Support asynchronous read and write operations |
||||
|
* Support multi-language culture support |
||||
|
* Support selective persistence of specified resources |
||||
|
|
||||
|
## Installation |
||||
|
|
||||
|
```bash |
||||
|
dotnet add package LINGYUN.Abp.Localization.Persistence |
||||
|
``` |
||||
|
|
||||
|
## Base Modules |
||||
|
|
||||
|
* Volo.Abp.Localization |
||||
|
|
||||
|
## Configuration |
||||
|
|
||||
|
The module provides the following configuration options: |
||||
|
|
||||
|
* SaveStaticLocalizationsToPersistence: Whether to enable localization resource persistence (default: true) |
||||
|
* SaveToPersistenceResources: List of resources to be persisted |
||||
|
|
||||
|
## Usage |
||||
|
|
||||
|
1. Add module dependency: |
||||
|
|
||||
|
```csharp |
||||
|
[DependsOn( |
||||
|
typeof(AbpLocalizationPersistenceModule))] |
||||
|
public class YouProjectModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<AbpLocalizationPersistenceOptions>(options => |
||||
|
{ |
||||
|
// Enable persistence facility |
||||
|
options.SaveStaticLocalizationsToPersistence = true; |
||||
|
|
||||
|
// Specify your localization resource type, static documents under this type will be persisted to storage facilities |
||||
|
options.AddPersistenceResource<YouProjectResource>(); |
||||
|
}); |
||||
|
|
||||
|
// Or use extension method to persist localization resource type |
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
// Same effect as above |
||||
|
options.UsePersistence<YouProjectResource>(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## Extension Interfaces |
||||
|
|
||||
|
### ILocalizationPersistenceReader |
||||
|
|
||||
|
Used to read localization resources from persistent storage: |
||||
|
|
||||
|
```csharp |
||||
|
public interface ILocalizationPersistenceReader |
||||
|
{ |
||||
|
// Get localized string for specified resource |
||||
|
LocalizedString GetOrNull(string resourceName, string cultureName, string name); |
||||
|
|
||||
|
// Fill localization dictionary |
||||
|
void Fill(string resourceName, string cultureName, Dictionary<string, LocalizedString> dictionary); |
||||
|
|
||||
|
// Asynchronously fill localization dictionary |
||||
|
Task FillAsync(string resourceName, string cultureName, Dictionary<string, LocalizedString> dictionary); |
||||
|
|
||||
|
// Get supported cultures list |
||||
|
Task<IEnumerable<string>> GetSupportedCulturesAsync(); |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### ILocalizationPersistenceWriter |
||||
|
|
||||
|
Used to write localization resources to persistent storage: |
||||
|
|
||||
|
```csharp |
||||
|
public interface ILocalizationPersistenceWriter |
||||
|
{ |
||||
|
// Write language information |
||||
|
Task<bool> WriteLanguageAsync(LanguageInfo language); |
||||
|
|
||||
|
// Write resource information |
||||
|
Task<bool> WriteResourceAsync(LocalizationResourceBase resource); |
||||
|
|
||||
|
// Get existing texts |
||||
|
Task<IEnumerable<string>> GetExistsTextsAsync( |
||||
|
string resourceName, |
||||
|
string cultureName, |
||||
|
IEnumerable<string> keys); |
||||
|
|
||||
|
// Write localization texts |
||||
|
Task<bool> WriteTextsAsync(IEnumerable<LocalizableStringText> texts); |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## Custom Persistence Implementation |
||||
|
|
||||
|
To implement custom persistence storage, you need to: |
||||
|
|
||||
|
1. Implement `ILocalizationPersistenceReader` interface |
||||
|
2. Implement `ILocalizationPersistenceWriter` interface |
||||
|
3. Register your implementation in the module: |
||||
|
|
||||
|
```csharp |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
context.Services.AddTransient<ILocalizationPersistenceReader, YourCustomReader>(); |
||||
|
context.Services.AddTransient<ILocalizationPersistenceWriter, YourCustomWriter>(); |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## More Information |
||||
|
|
||||
|
* [中文文档](./README.md) |
||||
|
* [ABP Localization Documentation](https://docs.abp.io/en/abp/latest/Localization) |
||||
@ -0,0 +1,102 @@ |
|||||
|
# LINGYUN.Abp.Localization.Xml |
||||
|
|
||||
|
## Module Description |
||||
|
|
||||
|
XML document integration module for localization components, providing XML file-based localization resource support. It includes built-in implementations for both PhysicalFileProvider and VirtualFileProvider. |
||||
|
|
||||
|
## Features |
||||
|
|
||||
|
* Support reading localization resources from XML files |
||||
|
* Support XML files in virtual file system |
||||
|
* Support XML files in physical file system |
||||
|
* Support XML file serialization and deserialization |
||||
|
* Support UTF-8 encoded XML files |
||||
|
|
||||
|
## Installation |
||||
|
|
||||
|
```bash |
||||
|
dotnet add package LINGYUN.Abp.Localization.Xml |
||||
|
``` |
||||
|
|
||||
|
## Base Modules |
||||
|
|
||||
|
* Volo.Abp.Localization |
||||
|
|
||||
|
## Usage |
||||
|
|
||||
|
1. Add module dependency: |
||||
|
|
||||
|
```csharp |
||||
|
[DependsOn( |
||||
|
typeof(AbpLocalizationXmlModule))] |
||||
|
public class YouProjectModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<AbpVirtualFileSystemOptions>(options => |
||||
|
{ |
||||
|
options.FileSets.AddEmbedded<YouProjectModule>(); |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Resources |
||||
|
.Add<YouResource>("en") |
||||
|
// Virtual file system directory in current project |
||||
|
// See: https://docs.abp.io/en/abp/latest/Virtual-File-System |
||||
|
.AddVirtualXml("/LINGYUN/Abp/Localization/Xml/Resources") |
||||
|
// Usually configured in the host project, write the absolute path where XML files are stored |
||||
|
// See: https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.fileproviders.physicalfileprovider |
||||
|
.AddPhysicalXml(Path.Combine(Directory.GetCurrentDirectory(), "Resources")); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## XML File Format |
||||
|
|
||||
|
This module uses the [XmlLocalizationFile](./LINGYUN/Abp/Localization/Xml/XmlLocalizationFile.cs) type for XML file serialization and deserialization. |
||||
|
|
||||
|
Example XML file format: |
||||
|
|
||||
|
```xml |
||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<localization> |
||||
|
<culture name="en"/> |
||||
|
<texts> |
||||
|
<text name="Welcome">Welcome</text> |
||||
|
<text name="HelloWorld">Hello, World!</text> |
||||
|
<text name="ThisFieldIsRequired">This field is required</text> |
||||
|
</texts> |
||||
|
</localization> |
||||
|
``` |
||||
|
|
||||
|
## Extension Methods |
||||
|
|
||||
|
The module provides two extension methods for adding XML localization resources: |
||||
|
|
||||
|
1. AddVirtualXml: Add XML files from virtual file system |
||||
|
```csharp |
||||
|
localizationResource.AddVirtualXml("/YourVirtualPath/Localization"); |
||||
|
``` |
||||
|
|
||||
|
2. AddPhysicalXml: Add XML files from physical file system |
||||
|
```csharp |
||||
|
localizationResource.AddPhysicalXml("C:/YourPath/Localization"); |
||||
|
``` |
||||
|
|
||||
|
## Best Practices |
||||
|
|
||||
|
1. Recommended usage for virtual files: |
||||
|
* Embed XML files into the assembly |
||||
|
* Suitable for default localization resources that don't need dynamic modification |
||||
|
|
||||
|
2. Recommended usage for physical files: |
||||
|
* Store in a specific directory in the host project |
||||
|
* Suitable for localization resources that need dynamic modification or are managed by external systems |
||||
|
|
||||
|
## More Information |
||||
|
|
||||
|
* [中文文档](./README.md) |
||||
|
* [ABP Localization Documentation](https://docs.abp.io/en/abp/latest/Localization) |
||||
|
* [ABP Virtual File System](https://docs.abp.io/en/abp/latest/Virtual-File-System) |
||||
Loading…
Reference in new issue