2013-06-10 10:46:11 -07:00
|
|
|
using System;
|
2013-06-10 19:34:55 -07:00
|
|
|
using System.Collections.Concurrent;
|
2013-06-06 07:33:11 -07:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Globalization;
|
2013-06-10 10:46:11 -07:00
|
|
|
using System.IO;
|
2013-06-06 07:33:11 -07:00
|
|
|
using System.Linq;
|
2019-01-27 02:20:05 -07:00
|
|
|
using System.Reflection;
|
|
|
|
using System.Threading.Tasks;
|
2019-01-13 12:22:00 -07:00
|
|
|
using MediaBrowser.Controller.Configuration;
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
using MediaBrowser.Model.Globalization;
|
|
|
|
using MediaBrowser.Model.Serialization;
|
|
|
|
using Microsoft.Extensions.Logging;
|
2013-06-06 07:33:11 -07:00
|
|
|
|
2016-11-04 19:17:18 -07:00
|
|
|
namespace Emby.Server.Implementations.Localization
|
2013-06-06 07:33:11 -07:00
|
|
|
{
|
|
|
|
/// <summary>
|
2019-08-16 08:31:47 -07:00
|
|
|
/// Class LocalizationManager.
|
2013-06-06 07:33:11 -07:00
|
|
|
/// </summary>
|
|
|
|
public class LocalizationManager : ILocalizationManager
|
|
|
|
{
|
2019-08-16 08:31:47 -07:00
|
|
|
private const string DefaultCulture = "en-US";
|
|
|
|
private static readonly Assembly _assembly = typeof(LocalizationManager).Assembly;
|
|
|
|
private static readonly string[] _unratedValues = { "n/a", "unrated", "not rated" };
|
2013-06-10 10:46:11 -07:00
|
|
|
|
2019-08-16 08:31:47 -07:00
|
|
|
private readonly IServerConfigurationManager _configurationManager;
|
|
|
|
private readonly IJsonSerializer _jsonSerializer;
|
|
|
|
private readonly ILogger _logger;
|
2013-06-10 10:46:11 -07:00
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
private readonly Dictionary<string, Dictionary<string, ParentalRating>> _allParentalRatings =
|
|
|
|
new Dictionary<string, Dictionary<string, ParentalRating>>(StringComparer.OrdinalIgnoreCase);
|
2013-06-10 19:34:55 -07:00
|
|
|
|
2019-08-16 08:31:47 -07:00
|
|
|
private readonly ConcurrentDictionary<string, Dictionary<string, string>> _dictionaries =
|
|
|
|
new ConcurrentDictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
|
|
|
private List<CultureDto> _cultures;
|
2014-03-30 18:00:47 -07:00
|
|
|
|
2013-06-10 10:46:11 -07:00
|
|
|
/// <summary>
|
2014-06-04 19:32:40 -07:00
|
|
|
/// Initializes a new instance of the <see cref="LocalizationManager" /> class.
|
2013-06-10 10:46:11 -07:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="configurationManager">The configuration manager.</param>
|
2014-06-04 19:32:40 -07:00
|
|
|
/// <param name="jsonSerializer">The json serializer.</param>
|
2019-08-16 08:31:47 -07:00
|
|
|
/// <param name="logger">The logger.</param>
|
2019-01-17 15:55:05 -07:00
|
|
|
public LocalizationManager(
|
|
|
|
IServerConfigurationManager configurationManager,
|
|
|
|
IJsonSerializer jsonSerializer,
|
2019-08-16 08:31:47 -07:00
|
|
|
ILogger<LocalizationManager> logger)
|
2013-06-10 10:46:11 -07:00
|
|
|
{
|
|
|
|
_configurationManager = configurationManager;
|
2014-03-30 18:00:47 -07:00
|
|
|
_jsonSerializer = jsonSerializer;
|
2019-08-16 08:31:47 -07:00
|
|
|
_logger = logger;
|
2013-06-18 13:54:32 -07:00
|
|
|
}
|
|
|
|
|
2019-08-16 08:31:47 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Loads all resources into memory.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns><see cref="Task" />.</returns>
|
2019-01-27 02:20:05 -07:00
|
|
|
public async Task LoadAll()
|
2013-06-18 13:54:32 -07:00
|
|
|
{
|
2019-03-13 14:32:52 -07:00
|
|
|
const string RatingsResource = "Emby.Server.Implementations.Localization.Ratings.";
|
2013-06-18 13:54:32 -07:00
|
|
|
|
|
|
|
// Extract from the assembly
|
2019-02-04 10:46:36 -07:00
|
|
|
foreach (var resource in _assembly.GetManifestResourceNames())
|
2013-06-18 13:54:32 -07:00
|
|
|
{
|
2019-03-13 14:32:52 -07:00
|
|
|
if (!resource.StartsWith(RatingsResource, StringComparison.Ordinal))
|
2019-02-04 10:46:36 -07:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-03-13 14:32:52 -07:00
|
|
|
string countryCode = resource.Substring(RatingsResource.Length, 2);
|
2019-03-01 11:30:48 -07:00
|
|
|
var dict = new Dictionary<string, ParentalRating>(StringComparer.OrdinalIgnoreCase);
|
2016-06-30 16:17:49 -07:00
|
|
|
|
2019-03-01 11:30:48 -07:00
|
|
|
using (var str = _assembly.GetManifestResourceStream(resource))
|
|
|
|
using (var reader = new StreamReader(str))
|
2019-02-04 10:46:36 -07:00
|
|
|
{
|
2019-03-01 11:30:48 -07:00
|
|
|
string line;
|
2019-03-13 14:32:52 -07:00
|
|
|
while ((line = await reader.ReadLineAsync().ConfigureAwait(false)) != null)
|
2019-02-04 10:46:36 -07:00
|
|
|
{
|
2019-03-01 11:30:48 -07:00
|
|
|
if (string.IsNullOrWhiteSpace(line))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
string[] parts = line.Split(',');
|
|
|
|
if (parts.Length == 2
|
2019-08-16 08:31:47 -07:00
|
|
|
&& int.TryParse(parts[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out var value))
|
2019-03-01 11:30:48 -07:00
|
|
|
{
|
2019-08-16 08:31:47 -07:00
|
|
|
var name = parts[0];
|
|
|
|
dict.Add(name, new ParentalRating(name, value));
|
2019-03-01 11:30:48 -07:00
|
|
|
}
|
|
|
|
#if DEBUG
|
|
|
|
else
|
|
|
|
{
|
2019-03-06 09:31:52 -07:00
|
|
|
_logger.LogWarning("Malformed line in ratings file for country {CountryCode}", countryCode);
|
2019-03-01 11:30:48 -07:00
|
|
|
}
|
|
|
|
#endif
|
2013-06-18 13:54:32 -07:00
|
|
|
}
|
|
|
|
}
|
2017-11-05 14:51:23 -07:00
|
|
|
|
2019-03-01 11:30:48 -07:00
|
|
|
_allParentalRatings[countryCode] = dict;
|
2013-06-18 13:54:32 -07:00
|
|
|
}
|
2018-09-12 10:26:21 -07:00
|
|
|
|
2019-03-13 14:32:52 -07:00
|
|
|
await LoadCultures().ConfigureAwait(false);
|
2018-09-12 10:26:21 -07:00
|
|
|
}
|
|
|
|
|
2013-06-06 07:33:11 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the cultures.
|
|
|
|
/// </summary>
|
2019-08-16 08:31:47 -07:00
|
|
|
/// <returns><see cref="IEnumerable{CultureDto}" />.</returns>
|
|
|
|
public IEnumerable<CultureDto> GetCultures()
|
2019-01-27 02:20:05 -07:00
|
|
|
=> _cultures;
|
2017-11-05 14:51:23 -07:00
|
|
|
|
2019-01-27 02:20:05 -07:00
|
|
|
private async Task LoadCultures()
|
|
|
|
{
|
|
|
|
List<CultureDto> list = new List<CultureDto>();
|
2014-06-18 08:12:20 -07:00
|
|
|
|
2019-03-13 14:32:52 -07:00
|
|
|
const string ResourcePath = "Emby.Server.Implementations.Localization.iso6392.txt";
|
2014-05-06 19:28:19 -07:00
|
|
|
|
2019-03-13 14:32:52 -07:00
|
|
|
using (var stream = _assembly.GetManifestResourceStream(ResourcePath))
|
2019-01-27 02:20:05 -07:00
|
|
|
using (var reader = new StreamReader(stream))
|
2014-05-06 19:28:19 -07:00
|
|
|
{
|
2019-01-27 02:20:05 -07:00
|
|
|
while (!reader.EndOfStream)
|
2014-06-18 08:12:20 -07:00
|
|
|
{
|
2019-03-13 14:32:52 -07:00
|
|
|
var line = await reader.ReadLineAsync().ConfigureAwait(false);
|
2019-01-27 02:20:05 -07:00
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(line))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
var parts = line.Split('|');
|
|
|
|
|
|
|
|
if (parts.Length == 5)
|
2014-06-18 08:12:20 -07:00
|
|
|
{
|
2019-01-27 02:20:05 -07:00
|
|
|
string name = parts[3];
|
|
|
|
if (string.IsNullOrWhiteSpace(name))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2014-06-18 08:12:20 -07:00
|
|
|
|
2019-01-27 02:20:05 -07:00
|
|
|
string twoCharName = parts[2];
|
|
|
|
if (string.IsNullOrWhiteSpace(twoCharName))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2014-06-18 08:12:20 -07:00
|
|
|
|
2019-01-27 02:20:05 -07:00
|
|
|
string[] threeletterNames;
|
|
|
|
if (string.IsNullOrWhiteSpace(parts[1]))
|
2014-06-18 08:12:20 -07:00
|
|
|
{
|
2019-03-13 14:32:52 -07:00
|
|
|
threeletterNames = new[] { parts[0] };
|
2014-06-18 08:12:20 -07:00
|
|
|
}
|
2019-01-27 02:20:05 -07:00
|
|
|
else
|
2014-06-18 08:12:20 -07:00
|
|
|
{
|
2019-03-13 14:32:52 -07:00
|
|
|
threeletterNames = new[] { parts[0], parts[1] };
|
2014-06-18 08:12:20 -07:00
|
|
|
}
|
2019-01-27 02:20:05 -07:00
|
|
|
|
|
|
|
list.Add(new CultureDto
|
|
|
|
{
|
|
|
|
DisplayName = name,
|
|
|
|
Name = name,
|
|
|
|
ThreeLetterISOLanguageNames = threeletterNames,
|
|
|
|
TwoLetterISOLanguageName = twoCharName
|
|
|
|
});
|
2014-06-18 08:12:20 -07:00
|
|
|
}
|
|
|
|
}
|
2014-05-06 19:28:19 -07:00
|
|
|
}
|
2014-06-18 08:12:20 -07:00
|
|
|
|
2019-08-16 08:31:47 -07:00
|
|
|
_cultures = list;
|
2013-06-06 07:33:11 -07:00
|
|
|
}
|
|
|
|
|
2019-08-16 08:31:47 -07:00
|
|
|
/// <inheritdoc />
|
2018-09-12 10:26:21 -07:00
|
|
|
public CultureDto FindLanguageInfo(string language)
|
2019-01-27 02:20:05 -07:00
|
|
|
=> GetCultures()
|
|
|
|
.FirstOrDefault(i =>
|
|
|
|
string.Equals(i.DisplayName, language, StringComparison.OrdinalIgnoreCase)
|
|
|
|
|| string.Equals(i.Name, language, StringComparison.OrdinalIgnoreCase)
|
|
|
|
|| i.ThreeLetterISOLanguageNames.Contains(language, StringComparer.OrdinalIgnoreCase)
|
|
|
|
|| string.Equals(i.TwoLetterISOLanguageName, language, StringComparison.OrdinalIgnoreCase));
|
2018-09-12 10:26:21 -07:00
|
|
|
|
2019-08-16 08:31:47 -07:00
|
|
|
/// <inheritdoc />
|
|
|
|
public IEnumerable<CountryInfo> GetCountries()
|
|
|
|
=> _jsonSerializer.DeserializeFromStream<IEnumerable<CountryInfo>>(
|
2019-01-27 02:20:05 -07:00
|
|
|
_assembly.GetManifestResourceStream("Emby.Server.Implementations.Localization.countries.json"));
|
2013-06-06 07:33:11 -07:00
|
|
|
|
2019-08-16 08:31:47 -07:00
|
|
|
/// <inheritdoc />
|
2019-01-27 02:20:05 -07:00
|
|
|
public IEnumerable<ParentalRating> GetParentalRatings()
|
|
|
|
=> GetParentalRatingsDictionary().Values;
|
2013-06-10 19:34:55 -07:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the parental ratings dictionary.
|
|
|
|
/// </summary>
|
2019-08-16 08:31:47 -07:00
|
|
|
/// <returns><see cref="Dictionary{String, ParentalRating}" />.</returns>
|
2013-06-10 19:34:55 -07:00
|
|
|
private Dictionary<string, ParentalRating> GetParentalRatingsDictionary()
|
|
|
|
{
|
|
|
|
var countryCode = _configurationManager.Configuration.MetadataCountryCode;
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(countryCode))
|
|
|
|
{
|
|
|
|
countryCode = "us";
|
|
|
|
}
|
|
|
|
|
2019-08-16 08:31:47 -07:00
|
|
|
return GetRatings(countryCode) ?? GetRatings("us");
|
2013-06-10 19:34:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the ratings.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="countryCode">The country code.</param>
|
2019-08-16 08:31:47 -07:00
|
|
|
/// <returns>The ratings.</returns>
|
2013-06-10 19:34:55 -07:00
|
|
|
private Dictionary<string, ParentalRating> GetRatings(string countryCode)
|
|
|
|
{
|
2019-01-13 13:46:33 -07:00
|
|
|
_allParentalRatings.TryGetValue(countryCode, out var value);
|
2013-06-10 19:34:55 -07:00
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2019-03-13 14:32:52 -07:00
|
|
|
/// <inheritdoc />
|
2013-06-10 10:46:11 -07:00
|
|
|
public int? GetRatingLevel(string rating)
|
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(rating))
|
|
|
|
{
|
2019-01-06 13:50:43 -07:00
|
|
|
throw new ArgumentNullException(nameof(rating));
|
2013-06-10 10:46:11 -07:00
|
|
|
}
|
|
|
|
|
2015-11-06 08:02:22 -07:00
|
|
|
if (_unratedValues.Contains(rating, StringComparer.OrdinalIgnoreCase))
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-05-11 09:32:15 -07:00
|
|
|
// Fairly common for some users to have "Rated R" in their rating field
|
|
|
|
rating = rating.Replace("Rated ", string.Empty, StringComparison.OrdinalIgnoreCase);
|
|
|
|
|
2013-06-10 19:34:55 -07:00
|
|
|
var ratingsDictionary = GetParentalRatingsDictionary();
|
2013-06-10 10:46:11 -07:00
|
|
|
|
2019-01-17 10:47:41 -07:00
|
|
|
if (ratingsDictionary.TryGetValue(rating, out ParentalRating value))
|
2013-06-10 19:34:55 -07:00
|
|
|
{
|
2018-09-12 10:26:21 -07:00
|
|
|
return value.Value;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we don't find anything check all ratings systems
|
|
|
|
foreach (var dictionary in _allParentalRatings.Values)
|
|
|
|
{
|
|
|
|
if (dictionary.TryGetValue(rating, out value))
|
2013-06-18 13:54:32 -07:00
|
|
|
{
|
2018-09-12 10:26:21 -07:00
|
|
|
return value.Value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try splitting by : to handle "Germany: FSK 18"
|
|
|
|
var index = rating.IndexOf(':');
|
|
|
|
if (index != -1)
|
|
|
|
{
|
|
|
|
rating = rating.Substring(index).TrimStart(':').Trim();
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(rating))
|
|
|
|
{
|
|
|
|
return GetRatingLevel(rating);
|
2013-06-18 13:54:32 -07:00
|
|
|
}
|
2013-06-10 19:34:55 -07:00
|
|
|
}
|
2013-06-10 10:46:11 -07:00
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
// TODO: Further improve by normalizing out all spaces and dashes
|
|
|
|
return null;
|
2013-06-10 10:46:11 -07:00
|
|
|
}
|
2014-03-30 18:00:47 -07:00
|
|
|
|
2019-08-16 08:31:47 -07:00
|
|
|
/// <inheritdoc />
|
2017-11-01 12:50:16 -07:00
|
|
|
public bool HasUnicodeCategory(string value, UnicodeCategory category)
|
|
|
|
{
|
|
|
|
foreach (var chr in value)
|
|
|
|
{
|
|
|
|
if (char.GetUnicodeCategory(chr) == category)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-08-16 08:31:47 -07:00
|
|
|
/// <inheritdoc />
|
2014-03-30 18:00:47 -07:00
|
|
|
public string GetLocalizedString(string phrase)
|
|
|
|
{
|
|
|
|
return GetLocalizedString(phrase, _configurationManager.Configuration.UICulture);
|
|
|
|
}
|
|
|
|
|
2019-08-16 08:31:47 -07:00
|
|
|
/// <inheritdoc />
|
2014-03-30 18:00:47 -07:00
|
|
|
public string GetLocalizedString(string phrase, string culture)
|
|
|
|
{
|
2018-09-12 10:26:21 -07:00
|
|
|
if (string.IsNullOrEmpty(culture))
|
2017-10-20 09:16:56 -07:00
|
|
|
{
|
|
|
|
culture = _configurationManager.Configuration.UICulture;
|
|
|
|
}
|
2019-03-13 14:32:52 -07:00
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
if (string.IsNullOrEmpty(culture))
|
2017-10-21 09:39:52 -07:00
|
|
|
{
|
|
|
|
culture = DefaultCulture;
|
|
|
|
}
|
2017-10-20 09:16:56 -07:00
|
|
|
|
2014-03-30 18:00:47 -07:00
|
|
|
var dictionary = GetLocalizationDictionary(culture);
|
|
|
|
|
2019-01-13 13:46:33 -07:00
|
|
|
if (dictionary.TryGetValue(phrase, out var value))
|
2014-03-30 18:00:47 -07:00
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return phrase;
|
|
|
|
}
|
|
|
|
|
2019-08-16 08:31:47 -07:00
|
|
|
private Dictionary<string, string> GetLocalizationDictionary(string culture)
|
2014-03-30 18:00:47 -07:00
|
|
|
{
|
2018-09-12 10:26:21 -07:00
|
|
|
if (string.IsNullOrEmpty(culture))
|
2017-10-21 09:39:52 -07:00
|
|
|
{
|
2019-01-06 13:50:43 -07:00
|
|
|
throw new ArgumentNullException(nameof(culture));
|
2017-10-21 09:39:52 -07:00
|
|
|
}
|
|
|
|
|
2015-07-27 11:18:10 -07:00
|
|
|
const string prefix = "Core";
|
2014-03-30 18:00:47 -07:00
|
|
|
var key = prefix + culture;
|
|
|
|
|
2019-08-16 08:31:47 -07:00
|
|
|
return _dictionaries.GetOrAdd(
|
|
|
|
key,
|
|
|
|
f => GetDictionary(prefix, culture, DefaultCulture + ".json").GetAwaiter().GetResult());
|
2014-03-30 18:00:47 -07:00
|
|
|
}
|
|
|
|
|
2019-01-27 02:20:05 -07:00
|
|
|
private async Task<Dictionary<string, string>> GetDictionary(string prefix, string culture, string baseFilename)
|
2014-03-30 18:00:47 -07:00
|
|
|
{
|
2018-09-12 10:26:21 -07:00
|
|
|
if (string.IsNullOrEmpty(culture))
|
2017-10-21 09:39:52 -07:00
|
|
|
{
|
2019-01-06 13:50:43 -07:00
|
|
|
throw new ArgumentNullException(nameof(culture));
|
2017-10-21 09:39:52 -07:00
|
|
|
}
|
|
|
|
|
2014-03-30 18:00:47 -07:00
|
|
|
var dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
|
|
|
var namespaceName = GetType().Namespace + "." + prefix;
|
|
|
|
|
2019-03-13 14:32:52 -07:00
|
|
|
await CopyInto(dictionary, namespaceName + "." + baseFilename).ConfigureAwait(false);
|
|
|
|
await CopyInto(dictionary, namespaceName + "." + GetResourceFilename(culture)).ConfigureAwait(false);
|
2014-03-30 18:00:47 -07:00
|
|
|
|
|
|
|
return dictionary;
|
|
|
|
}
|
|
|
|
|
2019-01-27 02:20:05 -07:00
|
|
|
private async Task CopyInto(IDictionary<string, string> dictionary, string resourcePath)
|
2014-03-30 18:00:47 -07:00
|
|
|
{
|
2019-01-27 02:20:05 -07:00
|
|
|
using (var stream = _assembly.GetManifestResourceStream(resourcePath))
|
2014-03-30 18:00:47 -07:00
|
|
|
{
|
2019-02-08 02:03:38 -07:00
|
|
|
// If a Culture doesn't have a translation the stream will be null and it defaults to en-us further up the chain
|
|
|
|
if (stream != null)
|
2019-01-27 02:20:05 -07:00
|
|
|
{
|
2019-03-13 14:32:52 -07:00
|
|
|
var dict = await _jsonSerializer.DeserializeFromStreamAsync<Dictionary<string, string>>(stream).ConfigureAwait(false);
|
2019-02-08 02:03:38 -07:00
|
|
|
|
|
|
|
foreach (var key in dict.Keys)
|
|
|
|
{
|
|
|
|
dictionary[key] = dict[key];
|
|
|
|
}
|
2014-03-30 18:00:47 -07:00
|
|
|
}
|
2019-02-08 02:26:29 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
_logger.LogError("Missing translation/culture resource: {ResourcePath}", resourcePath);
|
|
|
|
}
|
2014-03-30 18:00:47 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-06 13:50:43 -07:00
|
|
|
private static string GetResourceFilename(string culture)
|
2014-03-30 18:00:47 -07:00
|
|
|
{
|
|
|
|
var parts = culture.Split('-');
|
|
|
|
|
|
|
|
if (parts.Length == 2)
|
|
|
|
{
|
2019-01-27 04:03:43 -07:00
|
|
|
culture = parts[0].ToLowerInvariant() + "-" + parts[1].ToUpperInvariant();
|
2014-03-30 18:00:47 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-27 04:03:43 -07:00
|
|
|
culture = culture.ToLowerInvariant();
|
2014-03-30 18:00:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return culture + ".json";
|
|
|
|
}
|
|
|
|
|
2019-08-16 08:31:47 -07:00
|
|
|
/// <inheritdoc />
|
|
|
|
public IEnumerable<LocalizationOption> GetLocalizationOptions()
|
|
|
|
{
|
|
|
|
yield return new LocalizationOption("Arabic", "ar");
|
|
|
|
yield return new LocalizationOption("Bulgarian (Bulgaria)", "bg-BG");
|
|
|
|
yield return new LocalizationOption("Catalan", "ca");
|
|
|
|
yield return new LocalizationOption("Chinese Simplified", "zh-CN");
|
|
|
|
yield return new LocalizationOption("Chinese Traditional", "zh-TW");
|
|
|
|
yield return new LocalizationOption("Croatian", "hr");
|
|
|
|
yield return new LocalizationOption("Czech", "cs");
|
|
|
|
yield return new LocalizationOption("Danish", "da");
|
|
|
|
yield return new LocalizationOption("Dutch", "nl");
|
|
|
|
yield return new LocalizationOption("English (United Kingdom)", "en-GB");
|
|
|
|
yield return new LocalizationOption("English (United States)", "en-US");
|
|
|
|
yield return new LocalizationOption("French", "fr");
|
|
|
|
yield return new LocalizationOption("French (Canada)", "fr-CA");
|
|
|
|
yield return new LocalizationOption("German", "de");
|
|
|
|
yield return new LocalizationOption("Greek", "el");
|
|
|
|
yield return new LocalizationOption("Hebrew", "he");
|
|
|
|
yield return new LocalizationOption("Hungarian", "hu");
|
|
|
|
yield return new LocalizationOption("Italian", "it");
|
|
|
|
yield return new LocalizationOption("Kazakh", "kk");
|
|
|
|
yield return new LocalizationOption("Korean", "ko");
|
|
|
|
yield return new LocalizationOption("Lithuanian", "lt-LT");
|
|
|
|
yield return new LocalizationOption("Malay", "ms");
|
|
|
|
yield return new LocalizationOption("Norwegian Bokmål", "nb");
|
|
|
|
yield return new LocalizationOption("Persian", "fa");
|
|
|
|
yield return new LocalizationOption("Polish", "pl");
|
|
|
|
yield return new LocalizationOption("Portuguese (Brazil)", "pt-BR");
|
|
|
|
yield return new LocalizationOption("Portuguese (Portugal)", "pt-PT");
|
|
|
|
yield return new LocalizationOption("Russian", "ru");
|
|
|
|
yield return new LocalizationOption("Slovak", "sk");
|
|
|
|
yield return new LocalizationOption("Slovenian (Slovenia)", "sl-SI");
|
|
|
|
yield return new LocalizationOption("Spanish", "es");
|
|
|
|
yield return new LocalizationOption("Spanish (Argentina)", "es-AR");
|
|
|
|
yield return new LocalizationOption("Spanish (Mexico)", "es-MX");
|
|
|
|
yield return new LocalizationOption("Swedish", "sv");
|
|
|
|
yield return new LocalizationOption("Swiss German", "gsw");
|
|
|
|
yield return new LocalizationOption("Turkish", "tr");
|
|
|
|
}
|
2013-06-06 07:33:11 -07:00
|
|
|
}
|
|
|
|
}
|