Introduce Culture model to avoid CultureInfo.DisplayName issue
This commit is contained in:
		| @ -1,6 +1,9 @@ | ||||
| using System.Collections.Generic; | ||||
| using System.Globalization; | ||||
| using System.Linq; | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| using Oqtane.Infrastructure; | ||||
| using Oqtane.Models; | ||||
| using Oqtane.Shared; | ||||
|  | ||||
| namespace Oqtane.Controllers | ||||
| @ -17,10 +20,23 @@ namespace Oqtane.Controllers | ||||
|  | ||||
|         // GET: api/localization/getSupportedCultures | ||||
|         [HttpGet("getSupportedCultures")] | ||||
|         public IEnumerable<string> GetSupportedCultures() => _localizationManager.GetSupportedCultures(); | ||||
|         public IEnumerable<Culture> GetSupportedCultures() | ||||
|             => _localizationManager.GetSupportedCultures().Select(c => new Culture { | ||||
|                 Name = CultureInfo.GetCultureInfo(c).Name, | ||||
|                 DisplayName = CultureInfo.GetCultureInfo(c).DisplayName | ||||
|             }); | ||||
|  | ||||
|         // GET api/localization/getDefaultCulture | ||||
|         [HttpGet("getDefaultCulture")] | ||||
|         public string GetDefaultCulture() => _localizationManager.GetDefaultCulture(); | ||||
|         public Culture GetDefaultCulture() | ||||
|         { | ||||
|             var culture = _localizationManager.GetDefaultCulture(); | ||||
|  | ||||
|             return new Culture | ||||
|             { | ||||
|                 Name = CultureInfo.GetCultureInfo(culture).Name, | ||||
|                 DisplayName = CultureInfo.GetCultureInfo(culture).DisplayName | ||||
|             }; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 hishamco
					hishamco