diff --git a/MediaBrowser.Api/LocalizationService.cs b/MediaBrowser.Api/LocalizationService.cs
index 60270a3895..be86090ac4 100644
--- a/MediaBrowser.Api/LocalizationService.cs
+++ b/MediaBrowser.Api/LocalizationService.cs
@@ -31,6 +31,14 @@ namespace MediaBrowser.Api
{
}
+ ///
+ /// Class ParentalRatings
+ ///
+ [Route("/Localization/Options", "GET", Summary = "Gets localization options")]
+ public class GetLocalizationOptions : IReturn>
+ {
+ }
+
///
/// Class CulturesService
///
@@ -62,6 +70,13 @@ namespace MediaBrowser.Api
return ToOptimizedSerializedResultUsingCache(result);
}
+ public object Get(GetLocalizationOptions request)
+ {
+ var result = _localization.GetLocalizationOptions().ToList();
+
+ return ToOptimizedSerializedResultUsingCache(result);
+ }
+
///
/// Gets the specified request.
///
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index 9b126420a5..5ed77356b8 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -1242,19 +1242,9 @@ namespace MediaBrowser.Api.Playback
}
else if (i == 14)
{
- if (videoRequest != null)
- {
- videoRequest.Framerate = int.Parse(val, UsCulture);
- }
+ request.StartTimeTicks = long.Parse(val, UsCulture);
}
else if (i == 15)
- {
- if (videoRequest != null)
- {
- request.StartTimeTicks = long.Parse(val, UsCulture);
- }
- }
- else if (i == 16)
{
if (videoRequest != null)
{
diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
index 96b36ac7fc..1a190b75e0 100644
--- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
@@ -276,7 +276,7 @@ namespace MediaBrowser.Api.Playback.Hls
? 0
: ((GetHlsVideoStream)state.VideoRequest).TimeStampOffsetMs;
- var itsOffset = itsOffsetMs == 0 ? string.Empty : string.Format("-itsoffset {0} ", TimeSpan.FromMilliseconds(itsOffsetMs).TotalSeconds);
+ var itsOffset = itsOffsetMs == 0 ? string.Empty : string.Format("-itsoffset {0} ", TimeSpan.FromMilliseconds(itsOffsetMs).TotalSeconds.ToString(UsCulture));
var threads = GetNumberOfThreads(state, false);
diff --git a/MediaBrowser.Controller/Localization/ILocalizationManager.cs b/MediaBrowser.Controller/Localization/ILocalizationManager.cs
index dde2f78781..f41940ed45 100644
--- a/MediaBrowser.Controller/Localization/ILocalizationManager.cs
+++ b/MediaBrowser.Controller/Localization/ILocalizationManager.cs
@@ -1,7 +1,7 @@
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Globalization;
+using System;
using System.Collections.Generic;
-using System.Threading.Tasks;
namespace MediaBrowser.Controller.Localization
{
@@ -31,5 +31,42 @@ namespace MediaBrowser.Controller.Localization
/// The rating.
/// System.Int32.
int? GetRatingLevel(string rating);
+
+ ///
+ /// Gets the localized string.
+ ///
+ /// The phrase.
+ /// The culture.
+ /// System.String.
+ string GetLocalizedString(string phrase, string culture);
+
+ ///
+ /// Gets the localized string.
+ ///
+ /// The phrase.
+ /// System.String.
+ string GetLocalizedString(string phrase);
+
+ ///
+ /// Localizes the document.
+ ///
+ /// The document.
+ /// The culture.
+ /// The token builder.
+ /// System.String.
+ string LocalizeDocument(string document, string culture, Func tokenBuilder);
+
+ ///
+ /// Gets the localization options.
+ ///
+ /// IEnumerable{LocalizatonOption}.
+ IEnumerable GetLocalizationOptions();
+
+ ///
+ /// Gets the java script localization dictionary.
+ ///
+ /// The culture.
+ /// Dictionary{System.StringSystem.String}.
+ Dictionary GetJavaScriptLocalizationDictionary(string culture);
}
}
diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
index d0caa3ad20..932d5d63dd 100644
--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs
+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
@@ -218,6 +218,8 @@ namespace MediaBrowser.Model.Configuration
public string ServerName { get; set; }
public string WanDdns { get; set; }
+ public string UICulture { get; set; }
+
public DlnaOptions DlnaOptions { get; set; }
///
@@ -281,6 +283,8 @@ namespace MediaBrowser.Model.Configuration
MetadataOptions = options.ToArray();
DlnaOptions = new DlnaOptions();
+
+ UICulture = "en-us";
}
}
diff --git a/MediaBrowser.Model/Globalization/CountryInfo.cs b/MediaBrowser.Model/Globalization/CountryInfo.cs
index 16aea8436b..9f5f00d80e 100644
--- a/MediaBrowser.Model/Globalization/CountryInfo.cs
+++ b/MediaBrowser.Model/Globalization/CountryInfo.cs
@@ -30,4 +30,10 @@ namespace MediaBrowser.Model.Globalization
/// The name of the three letter ISO region.
public string ThreeLetterISORegionName { get; set; }
}
+
+ public class LocalizatonOption
+ {
+ public string Name { get; set; }
+ public string Value { get; set; }
+ }
}
diff --git a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
index 08add952a7..5b65a60c8b 100644
--- a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
+++ b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
@@ -257,8 +257,12 @@ namespace MediaBrowser.Server.Implementations.IO
InternalBufferSize = 32767
};
- newWatcher.NotifyFilter = NotifyFilters.CreationTime | NotifyFilters.DirectoryName |
- NotifyFilters.FileName | NotifyFilters.LastWrite | NotifyFilters.Size;
+ newWatcher.NotifyFilter = NotifyFilters.CreationTime |
+ NotifyFilters.DirectoryName |
+ NotifyFilters.FileName |
+ NotifyFilters.LastWrite |
+ NotifyFilters.Size |
+ NotifyFilters.Attributes;
newWatcher.Created += watcher_Changed;
newWatcher.Deleted += watcher_Changed;
diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/en_US.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/en_US.json
new file mode 100644
index 0000000000..45f0d7e133
--- /dev/null
+++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/en_US.json
@@ -0,0 +1,21 @@
+{
+ "SettingsSaved": "Settings saved.",
+ "AddUser": "Add User",
+ "Users": "Users",
+ "Delete": "Delete",
+ "Administrator": "Administrator",
+ "Password": "Password",
+ "CreatePassword": "Create Password",
+ "DeleteImage": "Delete Image",
+ "DeleteImageConfirmation": "Are you sure you wish to delete this image?",
+ "FileReadCancelled": "The file read has been cancelled.",
+ "FileNotFound": "File not found.",
+ "FileReadError": "An error occurred while reading the file.",
+ "DeleteUser": "Delete User",
+ "DeleteUserConfirmation": "Are you sure you wish to delete {0}?",
+ "PasswordResetHeader": "Password Reset",
+ "PasswordResetComplete": "The password has been reset.",
+ "PasswordResetConfirmation": "Are you sure you wish to reset the password?",
+ "PasswordSaved": "Password saved.",
+ "PasswordMatchError": "Password and password confirmation must match."
+}
\ No newline at end of file
diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json
new file mode 100644
index 0000000000..41f8508a5f
--- /dev/null
+++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json
@@ -0,0 +1,21 @@
+{
+ "SettingsSaved": "Settings saved.",
+ "AddUser": "Add User",
+ "Users": "Users",
+ "Delete": "Delete",
+ "Administrator": "Administrator",
+ "Password": "Password",
+ "CreatePassword": "Create Password",
+ "DeleteImage": "Delete Image",
+ "DeleteImageConfirmation": "Are you sure you wish to delete this image?",
+ "FileReadCancelled": "The file read has been cancelled.",
+ "FileNotFound": "File not found.",
+ "FileReadError": "An error occurred while reading the file.",
+ "DeleteUser": "Delete User",
+ "DeleteUserConfirmation": "Are you sure you wish to delete {0}?",
+ "PasswordResetHeader": "Password Reset",
+ "PasswordResetComplete": "The password has been reset.",
+ "PasswordResetConfirmation": "Are you sure you wish to reset the password?",
+ "PasswordSaved": "Password saved.",
+ "PasswordMatchError": "Password and password confirmation must match."
+}
\ No newline at end of file
diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/pt_PT.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/pt_PT.json
new file mode 100644
index 0000000000..25d3ff9442
--- /dev/null
+++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/pt_PT.json
@@ -0,0 +1,21 @@
+{
+ "SettingsSaved": "Configura\u00e7\u00f5es guardadas.",
+ "AddUser": "Adicionar Utilizador",
+ "Users": "Utilizadores",
+ "Delete": "Apagar",
+ "Administrator": "Administrador",
+ "Password": "Senha",
+ "CreatePassword": "Criar Senha",
+ "DeleteImage": "Apagar Imagem",
+ "DeleteImageConfirmation": "Tem a certeza que pretende apagar a imagem?",
+ "FileReadCancelled": "The file read has been cancelled.",
+ "FileNotFound": "Ficheiro n\u00e3o encontrado",
+ "FileReadError": "Ocorreu um erro ao ler o ficheiro.",
+ "DeleteUser": "Apagar Utilizador",
+ "DeleteUserConfirmation": "Tem a certeza que pretende apagar {0}?",
+ "PasswordResetHeader": "Password Reset",
+ "PasswordResetComplete": "The password has been reset.",
+ "PasswordResetConfirmation": "Are you sure you wish to reset the password?",
+ "PasswordSaved": "Senha guardada.",
+ "PasswordMatchError": "Password and password confirmation must match."
+}
\ No newline at end of file
diff --git a/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs b/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs
index 0d428742ce..6f39c67597 100644
--- a/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs
+++ b/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs
@@ -1,9 +1,9 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Localization;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Globalization;
+using MediaBrowser.Model.Serialization;
using MoreLinq;
using System;
using System.Collections.Concurrent;
@@ -11,6 +11,8 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
+using System.Reflection;
+using MediaBrowser.Common.Extensions;
namespace MediaBrowser.Server.Implementations.Localization
{
@@ -33,15 +35,17 @@ namespace MediaBrowser.Server.Implementations.Localization
new ConcurrentDictionary>(StringComparer.OrdinalIgnoreCase);
private readonly IFileSystem _fileSystem;
-
+ private readonly IJsonSerializer _jsonSerializer;
+
///
/// Initializes a new instance of the class.
///
/// The configuration manager.
- public LocalizationManager(IServerConfigurationManager configurationManager, IFileSystem fileSystem)
+ public LocalizationManager(IServerConfigurationManager configurationManager, IFileSystem fileSystem, IJsonSerializer jsonSerializer)
{
_configurationManager = configurationManager;
_fileSystem = fileSystem;
+ _jsonSerializer = jsonSerializer;
ExtractAll();
}
@@ -241,5 +245,112 @@ namespace MediaBrowser.Server.Implementations.Localization
return value == null ? (int?)null : value.Value;
}
+
+ public string GetLocalizedString(string phrase)
+ {
+ return GetLocalizedString(phrase, _configurationManager.Configuration.UICulture);
+ }
+
+ public string GetLocalizedString(string phrase, string culture)
+ {
+ var dictionary = GetLocalizationDictionary(culture);
+
+ string value;
+
+ if (dictionary.TryGetValue(phrase, out value))
+ {
+ return value;
+ }
+
+ return phrase;
+ }
+
+ private readonly ConcurrentDictionary> _dictionaries =
+ new ConcurrentDictionary>(StringComparer.OrdinalIgnoreCase);
+
+ public Dictionary GetLocalizationDictionary(string culture)
+ {
+ const string prefix = "Server";
+ var key = prefix + culture;
+
+ return _dictionaries.GetOrAdd(key, k => GetDictionary(prefix, culture, "server.json"));
+ }
+
+ public Dictionary GetJavaScriptLocalizationDictionary(string culture)
+ {
+ const string prefix = "JavaScript";
+ var key = prefix + culture;
+
+ return _dictionaries.GetOrAdd(key, k => GetDictionary(prefix, culture, "javascript.json"));
+ }
+
+ private Dictionary GetDictionary(string prefix, string culture, string baseFilename)
+ {
+ var dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase);
+
+ var assembly = GetType().Assembly;
+ var namespaceName = GetType().Namespace + "." + prefix;
+
+ CopyInto(dictionary, namespaceName + "." + baseFilename, assembly);
+ CopyInto(dictionary, namespaceName + "." + GetResourceFilename(culture), assembly);
+
+ return dictionary;
+ }
+
+ private void CopyInto(IDictionary dictionary, string resourcePath, Assembly assembly)
+ {
+ using (var stream = assembly.GetManifestResourceStream(resourcePath))
+ {
+ if (stream != null)
+ {
+ var dict = _jsonSerializer.DeserializeFromStream>(stream);
+
+ foreach (var key in dict.Keys)
+ {
+ dictionary[key] = dict[key];
+ }
+ }
+ }
+ }
+
+ private string GetResourceFilename(string culture)
+ {
+ var parts = culture.Split('-');
+
+ if (parts.Length == 2)
+ {
+ culture = parts[0].ToLower() + "_" + parts[1].ToUpper();
+ }
+ else
+ {
+ culture = culture.ToLower();
+ }
+
+ return culture + ".json";
+ }
+
+ public IEnumerable GetLocalizationOptions()
+ {
+ return new List
+ {
+ new LocalizatonOption{ Name="English (United States)", Value="en-us"},
+ new LocalizatonOption{ Name="German", Value="de"},
+ new LocalizatonOption{ Name="Portuguese (Portugal)", Value="pt-PT"},
+ new LocalizatonOption{ Name="Russian", Value="ru"}
+
+ }.OrderBy(i => i.Name);
+ }
+
+ public string LocalizeDocument(string document, string culture, Func tokenBuilder)
+ {
+ foreach (var pair in GetLocalizationDictionary(culture).ToList())
+ {
+ var token = tokenBuilder(pair.Key);
+
+ document = document.Replace(token, pair.Value, StringComparison.Ordinal);
+ }
+
+ return document;
+ }
}
}
diff --git a/MediaBrowser.Server.Implementations/Localization/Server/de.json b/MediaBrowser.Server.Implementations/Localization/Server/de.json
new file mode 100644
index 0000000000..ab3271b50f
--- /dev/null
+++ b/MediaBrowser.Server.Implementations/Localization/Server/de.json
@@ -0,0 +1,17 @@
+{
+ "LabelExit": "Ende",
+ "LabelVisitCommunity": "Besuche die Community",
+ "LabelGithubWiki": "Github Wiki",
+ "LabelSwagger": "Swagger",
+ "LabelStandard": "Standard",
+ "LabelViewApiDocumentation": "Zeige Api Dokumentation",
+ "LabelBrowseLibrary": "Durchsuche Bibliothek",
+ "LabelConfigureMediaBrowser": "Konfiguriere Media Browser",
+ "LabelOpenLibraryViewer": "\u00d6ffne Bibliothekenansicht",
+ "LabelRestartServer": "Server neustarten",
+ "LabelShowLogWindow": "Zeige Log Fenster",
+ "LabelPrevious": "Vorheriges",
+ "LabelFinish": "Ende",
+ "LabelNext": "N\u00e4chstes",
+ "LabelYoureDone": "Du bist fertig!"
+}
\ No newline at end of file
diff --git a/MediaBrowser.Server.Implementations/Localization/Server/en_US.json b/MediaBrowser.Server.Implementations/Localization/Server/en_US.json
new file mode 100644
index 0000000000..f74cca1eb1
--- /dev/null
+++ b/MediaBrowser.Server.Implementations/Localization/Server/en_US.json
@@ -0,0 +1,17 @@
+{
+ "LabelExit": "Exit",
+ "LabelVisitCommunity": "Visit Community",
+ "LabelGithubWiki": "Github Wiki",
+ "LabelSwagger": "Swagger",
+ "LabelStandard": "Standard",
+ "LabelViewApiDocumentation": "View Api Documentation",
+ "LabelBrowseLibrary": "Browse Library",
+ "LabelConfigureMediaBrowser": "Configure Media Browser",
+ "LabelOpenLibraryViewer": "Open Library Viewer",
+ "LabelRestartServer": "Restart Server",
+ "LabelShowLogWindow": "Show Log Window",
+ "LabelPrevious": "Previous",
+ "LabelFinish": "Finish",
+ "LabelNext": "Next",
+ "LabelYoureDone": "You're Done!"
+}
\ No newline at end of file
diff --git a/MediaBrowser.Server.Implementations/Localization/Server/pt_PT.json b/MediaBrowser.Server.Implementations/Localization/Server/pt_PT.json
new file mode 100644
index 0000000000..7003147086
--- /dev/null
+++ b/MediaBrowser.Server.Implementations/Localization/Server/pt_PT.json
@@ -0,0 +1,17 @@
+{
+ "LabelExit": "Sair",
+ "LabelVisitCommunity": "Visitar a Comunidade",
+ "LabelGithubWiki": "Wiki Github",
+ "LabelSwagger": "Swagger",
+ "LabelStandard": "Padr\u00e3o",
+ "LabelViewApiDocumentation": "Ver Documenta\u00e7\u00e3o da API",
+ "LabelBrowseLibrary": "Navegar na Biblioteca",
+ "LabelConfigureMediaBrowser": "Configurar Media Browser",
+ "LabelOpenLibraryViewer": "Abrir Visualizador da Biblioteca",
+ "LabelRestartServer": "Reiniciar Servidor",
+ "LabelShowLogWindow": "Mostrar Janela de Log",
+ "LabelPrevious": "Anterior",
+ "LabelFinish": "Terminar",
+ "LabelNext": "Seguinte",
+ "LabelYoureDone": "Concluiu!"
+}
\ No newline at end of file
diff --git a/MediaBrowser.Server.Implementations/Localization/Server/ru.json b/MediaBrowser.Server.Implementations/Localization/Server/ru.json
new file mode 100644
index 0000000000..4cc6b90f7f
--- /dev/null
+++ b/MediaBrowser.Server.Implementations/Localization/Server/ru.json
@@ -0,0 +1,17 @@
+{
+ "LabelExit": "\u0412\u044b\u0445\u043e\u0434",
+ "LabelVisitCommunity": "\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u044c \u0421\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e",
+ "LabelGithubWiki": "\u0412\u0438\u043a\u0438 \u043d\u0430 Github",
+ "LabelSwagger": "\u041e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u0435",
+ "LabelStandard": "\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439",
+ "LabelViewApiDocumentation": "\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043f\u043e API",
+ "LabelBrowseLibrary": "\u041e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u044c \u041c\u0435\u0434\u0438\u0430\u0442\u0435\u043a\u0438",
+ "LabelConfigureMediaBrowser": "\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Media Browser",
+ "LabelOpenLibraryViewer": "\u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u041c\u0435\u0434\u0438\u0430\u0442\u0435\u043a\u0438",
+ "LabelRestartServer": "\u041f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440",
+ "LabelShowLogWindow": "\u041e\u043a\u043d\u043e \u0416\u0443\u0440\u043d\u0430\u043b\u0430",
+ "LabelPrevious": "\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435",
+ "LabelFinish": "\u0417\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c",
+ "LabelNext": "\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435",
+ "LabelYoureDone": "\u0412\u044b \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0438!"
+}
\ No newline at end of file
diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json
new file mode 100644
index 0000000000..62a4183911
--- /dev/null
+++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json
@@ -0,0 +1,17 @@
+{
+ "LabelExit": "Exit",
+ "LabelVisitCommunity": "Visit Community",
+ "LabelGithubWiki": "Github Wiki",
+ "LabelSwagger": "Swagger",
+ "LabelStandard": "Standard",
+ "LabelViewApiDocumentation": "View Api Documentation",
+ "LabelBrowseLibrary": "Browse Library",
+ "LabelConfigureMediaBrowser": "Configure Media Browser",
+ "LabelOpenLibraryViewer": "Open Library Viewer",
+ "LabelRestartServer": "Restart Server",
+ "LabelShowLogWindow": "Show Log Window",
+ "LabelPrevious": "Previous",
+ "LabelFinish": "Finish",
+ "LabelNext": "Next",
+ "LabelYoureDone": "You're Done!"
+}
\ No newline at end of file
diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
index 115bc01368..539b968c72 100644
--- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
+++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
@@ -282,6 +282,14 @@
+
+
+
+
+
+
+
+
@@ -386,6 +394,7 @@
PreserveNewest
+