From 1ddc193e588f6231c327a769b580f48cba03a77f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 6 Jun 2013 10:33:11 -0400 Subject: support xbmc naming convention for subtitles --- .../Localization/LocalizationManager.cs | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs (limited to 'MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs') diff --git a/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs b/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs new file mode 100644 index 000000000..8705d912f --- /dev/null +++ b/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs @@ -0,0 +1,65 @@ +using MediaBrowser.Controller.Localization; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Globalization; +using MoreLinq; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; + +namespace MediaBrowser.Server.Implementations.Localization +{ + /// + /// Class LocalizationManager + /// + public class LocalizationManager : ILocalizationManager + { + /// + /// Gets the cultures. + /// + /// IEnumerable{CultureDto}. + public IEnumerable GetCultures() + { + return CultureInfo.GetCultures(CultureTypes.AllCultures) + .OrderBy(c => c.DisplayName) + .DistinctBy(c => c.TwoLetterISOLanguageName + c.ThreeLetterISOLanguageName) + .Select(c => new CultureDto + { + Name = c.Name, + DisplayName = c.DisplayName, + ThreeLetterISOLanguageName = c.ThreeLetterISOLanguageName, + TwoLetterISOLanguageName = c.TwoLetterISOLanguageName + }); + } + + /// + /// Gets the countries. + /// + /// IEnumerable{CountryInfo}. + public IEnumerable GetCountries() + { + return CultureInfo.GetCultures(CultureTypes.SpecificCultures) + .Select(c => new RegionInfo(c.LCID)) + .OrderBy(c => c.DisplayName) + .DistinctBy(c => c.TwoLetterISORegionName) + .Select(c => new CountryInfo + { + Name = c.Name, + DisplayName = c.DisplayName, + TwoLetterISORegionName = c.TwoLetterISORegionName, + ThreeLetterISORegionName = c.ThreeLetterISORegionName + }); + } + + /// + /// Gets the parental ratings. + /// + /// IEnumerable{ParentalRating}. + public IEnumerable GetParentalRatings() + { + return Ratings.RatingsDict + .Select(k => new ParentalRating {Name = k.Key, Value = k.Value}) + .OrderBy(p => p.Value) + .Where(p => p.Value > 0); + } + } +} -- cgit v1.2.3