Skip to content

Commit

Permalink
Merge pull request #1281 from hishamco/localization-manager
Browse files Browse the repository at this point in the history
LocalizationManager enhancements
  • Loading branch information
sbwalker authored Apr 27, 2021
2 parents 722c234 + 55b69f0 commit 307f97c
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions Oqtane.Server/Infrastructure/LocalizationManager.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand All @@ -19,25 +21,19 @@ public LocalizationManager(IOptions<LocalizationOptions> localizationOptions)
}

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();
}
}
}

0 comments on commit 307f97c

Please sign in to comment.