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