diff --git a/Jellyfin.Plugin.Themerr/Api/ThemerrController.cs b/Jellyfin.Plugin.Themerr/Api/ThemerrController.cs index 858c2f3..a30cdd2 100644 --- a/Jellyfin.Plugin.Themerr/Api/ThemerrController.cs +++ b/Jellyfin.Plugin.Themerr/Api/ThemerrController.cs @@ -151,6 +151,9 @@ public ActionResult GetTranslations() // Get the current assembly var assembly = Assembly.GetExecutingAssembly(); + // Initialize the result dictionary + var result = new Dictionary(); + for (var i = 0; i < filePaths.Count; i++) { // construct the resource name @@ -167,9 +170,6 @@ public ActionResult GetTranslations() continue; } - // Initialize the result dictionary - var result = new Dictionary(); - // read the resource content using var reader = new StreamReader(stream); var json = reader.ReadToEnd(); @@ -179,35 +179,33 @@ public ActionResult GetTranslations() // Add the localized strings to the 'locale' key result["locale"] = localizedStrings; + } - // Now get the fallback resource - var fallbackResourceName = "Jellyfin.Plugin.Themerr.Locale.en.json"; - using var fallbackStream = assembly.GetManifestResourceStream(fallbackResourceName); + // Now get the fallback resource + var fallbackResourceName = "Jellyfin.Plugin.Themerr.Locale.en.json"; + using var fallbackStream = assembly.GetManifestResourceStream(fallbackResourceName); - if (fallbackStream != null) - { - // read the fallback resource content - using var fallbackReader = new StreamReader(fallbackStream); - var fallbackJson = fallbackReader.ReadToEnd(); + if (fallbackStream != null) + { + // read the fallback resource content + using var fallbackReader = new StreamReader(fallbackStream); + var fallbackJson = fallbackReader.ReadToEnd(); - // deserialize the fallback JSON content into a dictionary - var fallbackLocalizedStrings = - JsonConvert.DeserializeObject>(fallbackJson); + // deserialize the fallback JSON content into a dictionary + var fallbackLocalizedStrings = + JsonConvert.DeserializeObject>(fallbackJson); - // Add the fallback localized strings to the 'fallback' key - result["fallback"] = fallbackLocalizedStrings; - } - else - { - _logger.LogError("Fallback locale resource does not exist: {ResourceName}", fallbackResourceName); - } - - // return the result as a JSON object - return Ok(result); + // Add the fallback localized strings to the 'fallback' key + result["fallback"] = fallbackLocalizedStrings; + } + else + { + _logger.LogError("Fallback locale resource does not exist: {ResourceName}", fallbackResourceName); + return StatusCode(StatusCodes.Status500InternalServerError); } - // return an error if we get this far - return StatusCode(StatusCodes.Status500InternalServerError); + // return the result as a JSON object + return Ok(result); } ///