diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-04 22:17:18 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-04 22:17:18 -0400 |
| commit | 3c1447804b5de9a7d840c7158c3cb4e0a27f76e1 (patch) | |
| tree | b7ea2715a1a9feb5e6f36c26bca09b2a32996847 /MediaBrowser.Server.Startup.Common | |
| parent | 25312d7d03af665818cfd2cee2edb549e0e940f2 (diff) | |
move localization classes
Diffstat (limited to 'MediaBrowser.Server.Startup.Common')
3 files changed, 31 insertions, 4 deletions
diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index ba04338bb9..fd84940dd5 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -54,7 +54,6 @@ using MediaBrowser.Server.Implementations.Configuration; using MediaBrowser.Server.Implementations.Devices; using MediaBrowser.Server.Implementations.HttpServer; using MediaBrowser.Server.Implementations.IO; -using MediaBrowser.Server.Implementations.Localization; using MediaBrowser.Server.Implementations.Notifications; using MediaBrowser.Server.Implementations.Persistence; using MediaBrowser.Server.Implementations.Security; @@ -107,6 +106,7 @@ using Emby.Server.Implementations.FileOrganization; using Emby.Server.Implementations.HttpServer.Security; using Emby.Server.Implementations.Library; using Emby.Server.Implementations.LiveTv; +using Emby.Server.Implementations.Localization; using Emby.Server.Implementations.MediaEncoder; using Emby.Server.Implementations.Notifications; using Emby.Server.Implementations.Persistence; @@ -548,7 +548,10 @@ namespace MediaBrowser.Server.Startup.Common RegisterSingleInstance(ServerConfigurationManager); - LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer, LogManager.GetLogger("LocalizationManager")); + IAssemblyInfo assemblyInfo = new AssemblyInfo(); + RegisterSingleInstance<IAssemblyInfo>(assemblyInfo); + + LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer, LogManager.GetLogger("LocalizationManager"), assemblyInfo, new TextLocalizer()); StringExtensions.LocalizationManager = LocalizationManager; RegisterSingleInstance(LocalizationManager); @@ -558,8 +561,6 @@ namespace MediaBrowser.Server.Startup.Common RegisterSingleInstance<IBlurayExaminer>(() => new BdInfoExaminer(FileSystemManager, textEncoding)); RegisterSingleInstance<IXmlReaderSettingsFactory>(new XmlReaderSettingsFactory()); - IAssemblyInfo assemblyInfo = new AssemblyInfo(); - RegisterSingleInstance<IAssemblyInfo>(assemblyInfo); UserDataManager = new UserDataManager(LogManager, ServerConfigurationManager); RegisterSingleInstance(UserDataManager); diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj index d30d892c93..aca30aa2c4 100644 --- a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj +++ b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj @@ -89,6 +89,7 @@ <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="StartupOptions.cs" /> <Compile Include="SystemEvents.cs" /> + <Compile Include="TextLocalizer.cs" /> <Compile Include="Threading\PeriodicTimer.cs" /> <Compile Include="UnhandledExceptionWriter.cs" /> </ItemGroup> diff --git a/MediaBrowser.Server.Startup.Common/TextLocalizer.cs b/MediaBrowser.Server.Startup.Common/TextLocalizer.cs new file mode 100644 index 0000000000..c578199a07 --- /dev/null +++ b/MediaBrowser.Server.Startup.Common/TextLocalizer.cs @@ -0,0 +1,25 @@ +using System; +using System.Globalization; +using System.Linq; +using System.Text; +using Emby.Server.Implementations.Localization; + +namespace MediaBrowser.Server.Startup.Common +{ + public class TextLocalizer : ITextLocalizer + { + public string RemoveDiacritics(string text) + { + return String.Concat( + text.Normalize(NormalizationForm.FormD) + .Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) != + UnicodeCategory.NonSpacingMark) + ).Normalize(NormalizationForm.FormC); + } + + public string NormalizeFormKD(string text) + { + return text.Normalize(NormalizationForm.FormKD); + } + } +} |
