localize time zone names
This commit is contained in:
17
Oqtane.Client/Services/Interfaces/ITimeZoneService.cs
Normal file
17
Oqtane.Client/Services/Interfaces/ITimeZoneService.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Service to retrieve <see cref="TimeZone"/> entries
|
||||
/// </summary>
|
||||
public interface ITimeZoneService
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the list of time zones
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<TimeZone> GetTimeZones();
|
||||
}
|
||||
}
|
34
Oqtane.Client/Services/TimeZoneService.cs
Normal file
34
Oqtane.Client/Services/TimeZoneService.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Oqtane.Documentation;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
[PrivateApi("Don't show in the documentation, as everything should use the Interface")]
|
||||
public class TimeZoneService : ITimeZoneService
|
||||
{
|
||||
private readonly IStringLocalizer<TimeZoneResources> _TimeZoneLocalizer;
|
||||
|
||||
public TimeZoneService(IStringLocalizer<TimeZoneResources> TimeZoneLocalizer)
|
||||
{
|
||||
_TimeZoneLocalizer = TimeZoneLocalizer;
|
||||
}
|
||||
|
||||
public List<TimeZone> GetTimeZones()
|
||||
{
|
||||
var _timezones = new List<TimeZone>();
|
||||
foreach (var timezone in Utilities.GetTimeZones())
|
||||
{
|
||||
_timezones.Add(new TimeZone
|
||||
{
|
||||
Id = timezone.Id,
|
||||
DisplayName = _TimeZoneLocalizer[timezone.Id]
|
||||
});
|
||||
}
|
||||
return _timezones.OrderBy(item => item.DisplayName).ToList();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user