From 579a86a7085ca5f1d41d01c0fa2aa5e03f6ff1e9 Mon Sep 17 00:00:00 2001 From: Qstick Date: Fri, 4 Sep 2020 23:55:35 -0400 Subject: [PATCH] Don't Camel Case Localization Endpoint --- frontend/src/Calendar/CalendarPage.js | 2 +- frontend/src/Movie/Index/MovieIndex.js | 2 +- frontend/src/Settings/General/HostSettings.js | 6 +++--- .../Settings/Indexers/Options/IndexerOptions.js | 4 ++-- frontend/src/System/Status/About/About.js | 2 +- frontend/src/Utilities/String/translate.js | 5 ++--- .../Localization/LocalizationModule.cs | 16 +++++++++++++--- 7 files changed, 23 insertions(+), 14 deletions(-) diff --git a/frontend/src/Calendar/CalendarPage.js b/frontend/src/Calendar/CalendarPage.js index b087be106..c569a6532 100644 --- a/frontend/src/Calendar/CalendarPage.js +++ b/frontend/src/Calendar/CalendarPage.js @@ -110,7 +110,7 @@ class CalendarPage extends Component { - {translate('SslCertPath')} + {translate('SSLCertPath')} - {translate('RssSyncInterval')} + {translate('RSSSyncInterval')} diff --git a/frontend/src/Utilities/String/translate.js b/frontend/src/Utilities/String/translate.js index 7a3e97e75..01e162512 100644 --- a/frontend/src/Utilities/String/translate.js +++ b/frontend/src/Utilities/String/translate.js @@ -9,7 +9,7 @@ function getTranslations() { dataType: 'json', url: `${window.Radarr.apiRoot}/localization`, success: function(data) { - localization = data.strings; + localization = data.Strings; } }; @@ -34,6 +34,5 @@ export default function translate(key, args = '') { }); } - const formatedKey = key.charAt(0).toLowerCase() + key.slice(1); - return translations[formatedKey] || key; + return translations[key] || key; } diff --git a/src/Radarr.Api.V3/Localization/LocalizationModule.cs b/src/Radarr.Api.V3/Localization/LocalizationModule.cs index 8bebc5de9..1f02559a4 100644 --- a/src/Radarr.Api.V3/Localization/LocalizationModule.cs +++ b/src/Radarr.Api.V3/Localization/LocalizationModule.cs @@ -1,3 +1,4 @@ +using Newtonsoft.Json; using NzbDrone.Core.Localization; using Radarr.Http; @@ -11,12 +12,21 @@ namespace Radarr.Api.V3.Localization { _localizationService = localizationService; - GetResourceSingle = GetLocalizationDictionary; + Get("/", x => GetLocalizationDictionary()); } - private LocalizationResource GetLocalizationDictionary() + private string GetLocalizationDictionary() { - return _localizationService.GetLocalizationDictionary().ToResource(); + // We don't want camel case for transation strings, create new serializer settings + var serializerSettings = new JsonSerializerSettings + { + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + Formatting = Formatting.Indented, + DefaultValueHandling = DefaultValueHandling.Include + }; + + return JsonConvert.SerializeObject(_localizationService.GetLocalizationDictionary().ToResource(), serializerSettings); } } }