Merge pull request #1281 from hishamco/localization-manager
LocalizationManager enhancements
This commit is contained in:
commit
307f97c60c
@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Oqtane.Shared;
|
||||
@ -9,7 +11,7 @@ namespace Oqtane.Infrastructure
|
||||
public class LocalizationManager : ILocalizationManager
|
||||
{
|
||||
private static readonly string DefaultCulture = Constants.DefaultCulture;
|
||||
private static readonly string[] SupportedCultures = new[] { DefaultCulture };
|
||||
private static readonly string[] DefaultSupportedCultures = new[] { DefaultCulture };
|
||||
|
||||
private readonly LocalizationOptions _localizationOptions;
|
||||
|
||||
@ -19,25 +21,19 @@ namespace Oqtane.Infrastructure
|
||||
}
|
||||
|
||||
public string GetDefaultCulture()
|
||||
=> string.IsNullOrEmpty(_localizationOptions.DefaultCulture)
|
||||
=> String.IsNullOrEmpty(_localizationOptions.DefaultCulture)
|
||||
? DefaultCulture
|
||||
: _localizationOptions.DefaultCulture;
|
||||
|
||||
public string[] GetSupportedCultures()
|
||||
{
|
||||
List<string> cultures = new List<string>();
|
||||
var cultures = new List<string>(DefaultSupportedCultures);
|
||||
foreach(var file in Directory.EnumerateFiles(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Oqtane.Client.resources.dll", SearchOption.AllDirectories))
|
||||
{
|
||||
cultures.Add(Path.GetFileName(Path.GetDirectoryName(file)));
|
||||
}
|
||||
if (cultures.Count == 0)
|
||||
{
|
||||
return SupportedCultures;
|
||||
}
|
||||
else
|
||||
{
|
||||
return cultures.ToArray();
|
||||
}
|
||||
|
||||
return cultures.OrderBy(c => c).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user