aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Localization
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2017-08-13 16:21:10 -0400
committerGitHub <noreply@github.com>2017-08-13 16:21:10 -0400
commitdc578f3742b474bd85d556299a6b2763f4d9acda (patch)
treecc4a8d1de140ece77160349e51a64857656ab373 /Emby.Server.Implementations/Localization
parentf6ed934a7e32bf10c3a141773d713bf3b19e784f (diff)
parent7f200f057d33e3ef52b1b1b1bf1767577295317e (diff)
Merge pull request #2815 from MediaBrowser/beta
Beta
Diffstat (limited to 'Emby.Server.Implementations/Localization')
-rw-r--r--Emby.Server.Implementations/Localization/Core/en-US.json2
-rw-r--r--Emby.Server.Implementations/Localization/LocalizationManager.cs6
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/es.txt1
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/ro.txt1
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/us.txt1
-rw-r--r--Emby.Server.Implementations/Localization/TextLocalizer.cs63
6 files changed, 70 insertions, 4 deletions
diff --git a/Emby.Server.Implementations/Localization/Core/en-US.json b/Emby.Server.Implementations/Localization/Core/en-US.json
index bc0dc236d..133644ff7 100644
--- a/Emby.Server.Implementations/Localization/Core/en-US.json
+++ b/Emby.Server.Implementations/Localization/Core/en-US.json
@@ -69,7 +69,7 @@
"ViewTypeTvResume": "Resume",
"ViewTypeTvNextUp": "Next Up",
"ViewTypeTvLatest": "Latest",
- "ViewTypeTvShowSeries": "Series",
+ "ViewTypeTvShowSeries": "Shows",
"ViewTypeTvGenres": "Genres",
"ViewTypeTvFavoriteSeries": "Favorite Series",
"ViewTypeTvFavoriteEpisodes": "Favorite Episodes",
diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs
index 64a41acef..8d3051a89 100644
--- a/Emby.Server.Implementations/Localization/LocalizationManager.cs
+++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs
@@ -132,7 +132,7 @@ namespace Emby.Server.Implementations.Localization
/// Gets the cultures.
/// </summary>
/// <returns>IEnumerable{CultureDto}.</returns>
- public IEnumerable<CultureDto> GetCultures()
+ public List<CultureDto> GetCultures()
{
var type = GetType();
var path = type.Namespace + ".iso6392.txt";
@@ -169,14 +169,14 @@ namespace Emby.Server.Implementations.Localization
return list.Where(i => !string.IsNullOrWhiteSpace(i.Name) &&
!string.IsNullOrWhiteSpace(i.DisplayName) &&
!string.IsNullOrWhiteSpace(i.ThreeLetterISOLanguageName) &&
- !string.IsNullOrWhiteSpace(i.TwoLetterISOLanguageName));
+ !string.IsNullOrWhiteSpace(i.TwoLetterISOLanguageName)).ToList();
}
/// <summary>
/// Gets the countries.
/// </summary>
/// <returns>IEnumerable{CountryInfo}.</returns>
- public IEnumerable<CountryInfo> GetCountries()
+ public List<CountryInfo> GetCountries()
{
var type = GetType();
var path = type.Namespace + ".countries.json";
diff --git a/Emby.Server.Implementations/Localization/Ratings/es.txt b/Emby.Server.Implementations/Localization/Ratings/es.txt
index 1ba24fb99..32a1e6438 100644
--- a/Emby.Server.Implementations/Localization/Ratings/es.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/es.txt
@@ -1,4 +1,5 @@
ES-A,1
+ES-APTA,1
ES-7,3
ES-12,6
ES-16,8
diff --git a/Emby.Server.Implementations/Localization/Ratings/ro.txt b/Emby.Server.Implementations/Localization/Ratings/ro.txt
new file mode 100644
index 000000000..3fdaed9cc
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/ro.txt
@@ -0,0 +1 @@
+RO-AG,1 \ No newline at end of file
diff --git a/Emby.Server.Implementations/Localization/Ratings/us.txt b/Emby.Server.Implementations/Localization/Ratings/us.txt
index 3f5311e0e..9bd78c72b 100644
--- a/Emby.Server.Implementations/Localization/Ratings/us.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/us.txt
@@ -1,3 +1,4 @@
+APPROVED,1
G,1
E,1
EC,1
diff --git a/Emby.Server.Implementations/Localization/TextLocalizer.cs b/Emby.Server.Implementations/Localization/TextLocalizer.cs
new file mode 100644
index 000000000..5188a959e
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/TextLocalizer.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace Emby.Server.Implementations.Localization
+{
+ public class TextLocalizer : ITextLocalizer
+ {
+ public string RemoveDiacritics(string text)
+ {
+ if (text == null)
+ {
+ throw new ArgumentNullException("text");
+ }
+
+ var chars = Normalize(text, NormalizationForm.FormD)
+ .Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) != UnicodeCategory.NonSpacingMark);
+
+ return Normalize(String.Concat(chars), NormalizationForm.FormC);
+ }
+
+ private static string Normalize(string text, NormalizationForm form, bool stripStringOnFailure = true)
+ {
+ if (stripStringOnFailure)
+ {
+ try
+ {
+ return text.Normalize(form);
+ }
+ catch (ArgumentException)
+ {
+ // will throw if input contains invalid unicode chars
+ // https://mnaoumov.wordpress.com/2014/06/14/stripping-invalid-characters-from-utf-16-strings/
+ text = StripInvalidUnicodeCharacters(text);
+ return Normalize(text, form, false);
+ }
+ }
+
+ try
+ {
+ return text.Normalize(form);
+ }
+ catch (ArgumentException)
+ {
+ // if it still fails, return the original text
+ return text;
+ }
+ }
+
+ private static string StripInvalidUnicodeCharacters(string str)
+ {
+ var invalidCharactersRegex = new Regex("([\ud800-\udbff](?![\udc00-\udfff]))|((?<![\ud800-\udbff])[\udc00-\udfff])");
+ return invalidCharactersRegex.Replace(str, "");
+ }
+
+ public string NormalizeFormKD(string text)
+ {
+ return text.Normalize(NormalizationForm.FormKD);
+ }
+ }
+}