Use REST style
This commit is contained in:
parent
5ee38e4ae7
commit
1a8125c26d
|
@ -6,8 +6,6 @@ namespace Oqtane.Services
|
||||||
{
|
{
|
||||||
public interface ILocalizationService
|
public interface ILocalizationService
|
||||||
{
|
{
|
||||||
Task<Culture> GetDefaultCulture();
|
Task<IEnumerable<Culture>> GetCulturesAsync();
|
||||||
|
|
||||||
Task<IEnumerable<Culture>> GetSupportedCultures();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,6 @@ namespace Oqtane.Services
|
||||||
|
|
||||||
private string Apiurl => CreateApiUrl(_siteState.Alias, "Localization");
|
private string Apiurl => CreateApiUrl(_siteState.Alias, "Localization");
|
||||||
|
|
||||||
public async Task<Culture> GetDefaultCulture() => await GetJsonAsync<Culture>($"{Apiurl}/getDefaultCulture");
|
public async Task<IEnumerable<Culture>> GetCulturesAsync() => await GetJsonAsync<IEnumerable<Culture>>(Apiurl);
|
||||||
|
|
||||||
public async Task<IEnumerable<Culture>> GetSupportedCultures()
|
|
||||||
=> await GetJsonAsync<IEnumerable<Culture>>($"{Apiurl}/getSupportedCultures");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
{
|
{
|
||||||
var interop = new Interop(JSRuntime);
|
var interop = new Interop(JSRuntime);
|
||||||
_selectedCulture = await interop.GetLocalStorage("OqtaneCulture");
|
_selectedCulture = await interop.GetLocalStorage("OqtaneCulture");
|
||||||
_supportedCultures = await LocalizationService.GetSupportedCultures();
|
_supportedCultures = await LocalizationService.GetCulturesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SetCultureAsync(string culture)
|
private async Task SetCultureAsync(string culture)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -18,25 +19,14 @@ namespace Oqtane.Controllers
|
||||||
_localizationManager = localizationManager;
|
_localizationManager = localizationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/localization/getSupportedCultures
|
// GET: api/localization
|
||||||
[HttpGet("getSupportedCultures")]
|
[HttpGet()]
|
||||||
public IEnumerable<Culture> GetSupportedCultures()
|
public IEnumerable<Culture> Get()
|
||||||
=> _localizationManager.GetSupportedCultures().Select(c => new Culture {
|
=> _localizationManager.GetSupportedCultures().Select(c => new Culture {
|
||||||
Name = CultureInfo.GetCultureInfo(c).Name,
|
Name = CultureInfo.GetCultureInfo(c).Name,
|
||||||
DisplayName = CultureInfo.GetCultureInfo(c).DisplayName
|
DisplayName = CultureInfo.GetCultureInfo(c).DisplayName,
|
||||||
|
IsDefault = _localizationManager.GetDefaultCulture()
|
||||||
|
.Equals(CultureInfo.GetCultureInfo(c).Name, StringComparison.OrdinalIgnoreCase)
|
||||||
});
|
});
|
||||||
|
|
||||||
// GET api/localization/getDefaultCulture
|
|
||||||
[HttpGet("getDefaultCulture")]
|
|
||||||
public Culture GetDefaultCulture()
|
|
||||||
{
|
|
||||||
var culture = _localizationManager.GetDefaultCulture();
|
|
||||||
|
|
||||||
return new Culture
|
|
||||||
{
|
|
||||||
Name = CultureInfo.GetCultureInfo(culture).Name,
|
|
||||||
DisplayName = CultureInfo.GetCultureInfo(culture).DisplayName
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,5 +5,7 @@ namespace Oqtane.Models
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
public string DisplayName { get; set; }
|
public string DisplayName { get; set; }
|
||||||
|
|
||||||
|
public bool IsDefault { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user