Refactoring
This commit is contained in:
@ -0,0 +1,9 @@
|
||||
namespace Oqtane.Infrastructure
|
||||
{
|
||||
public interface ILocalizationManager
|
||||
{
|
||||
string GetDefaultCulture();
|
||||
|
||||
string[] GetSupportedCultures();
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace Oqtane.Infrastructure
|
||||
{
|
||||
public class LocalizationOptions
|
||||
{
|
||||
public string DefaultCulture { get; set; }
|
||||
|
||||
public string[] SupportedCultures { get; set; }
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Infrastructure.Localization
|
||||
{
|
||||
public static class LocalizationSettings
|
||||
{
|
||||
static LocalizationSettings()
|
||||
{
|
||||
DefaultCulture = Constants.DefaultCulture;
|
||||
SupportedCultures = new List<string> { DefaultCulture };
|
||||
}
|
||||
|
||||
public static string DefaultCulture { get; set; }
|
||||
|
||||
public static List<string> SupportedCultures { get; }
|
||||
}
|
||||
}
|
29
Oqtane.Server/Infrastructure/LocalizationManager.cs
Normal file
29
Oqtane.Server/Infrastructure/LocalizationManager.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Infrastructure
|
||||
{
|
||||
public class LocalizationManager : ILocalizationManager
|
||||
{
|
||||
private static readonly string DefaultCulture = Constants.DefaultCulture;
|
||||
private static readonly string[] SupportedCultures = new[] { DefaultCulture };
|
||||
|
||||
private readonly LocalizationOptions _localizationOptions;
|
||||
|
||||
public LocalizationManager(IOptions<LocalizationOptions> localizationOptions)
|
||||
{
|
||||
_localizationOptions = localizationOptions.Value;
|
||||
}
|
||||
|
||||
public string GetDefaultCulture()
|
||||
=> string.IsNullOrEmpty(_localizationOptions.DefaultCulture)
|
||||
? DefaultCulture
|
||||
: _localizationOptions.DefaultCulture;
|
||||
|
||||
public string[] GetSupportedCultures()
|
||||
=> _localizationOptions.SupportedCultures.IsNullOrEmpty()
|
||||
? SupportedCultures
|
||||
: _localizationOptions.SupportedCultures;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user