mirror of
https://github.com/fergalmoran/Readarr.git
synced 2026-01-23 17:14:10 +00:00
Fixed: Improve translation loading
(cherry picked from commit 73c5ec1da4dd00301e1b0dddbcea37590a99b045) Closes #2699
This commit is contained in:
@@ -10,7 +10,8 @@ namespace Readarr.Http.Frontend
|
||||
{
|
||||
[Authorize(Policy = "UI")]
|
||||
[ApiController]
|
||||
public class InitializeJsController : Controller
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
public class InitializeJsonController : Controller
|
||||
{
|
||||
private readonly IConfigFileProvider _configFileProvider;
|
||||
private readonly IAnalyticsService _analyticsService;
|
||||
@@ -19,7 +20,7 @@ namespace Readarr.Http.Frontend
|
||||
private static string _urlBase;
|
||||
private string _generatedContent;
|
||||
|
||||
public InitializeJsController(IConfigFileProvider configFileProvider,
|
||||
public InitializeJsonController(IConfigFileProvider configFileProvider,
|
||||
IAnalyticsService analyticsService)
|
||||
{
|
||||
_configFileProvider = configFileProvider;
|
||||
@@ -29,11 +30,10 @@ namespace Readarr.Http.Frontend
|
||||
_urlBase = configFileProvider.UrlBase;
|
||||
}
|
||||
|
||||
[HttpGet("/initialize.js")]
|
||||
[HttpGet("/initialize.json")]
|
||||
public IActionResult Index()
|
||||
{
|
||||
// TODO: Move away from window.Readarr and prefetch the information returned here when starting the UI
|
||||
return Content(GetContent(), "application/javascript");
|
||||
return Content(GetContent(), "application/json");
|
||||
}
|
||||
|
||||
private string GetContent()
|
||||
@@ -44,19 +44,19 @@ namespace Readarr.Http.Frontend
|
||||
}
|
||||
|
||||
var builder = new StringBuilder();
|
||||
builder.AppendLine("window.Readarr = {");
|
||||
builder.AppendLine($" apiRoot: '{_urlBase}/api/v1',");
|
||||
builder.AppendLine($" apiKey: '{_apiKey}',");
|
||||
builder.AppendLine($" release: '{BuildInfo.Release}',");
|
||||
builder.AppendLine($" version: '{BuildInfo.Version.ToString()}',");
|
||||
builder.AppendLine($" instanceName: '{_configFileProvider.InstanceName.ToString()}',");
|
||||
builder.AppendLine($" theme: '{_configFileProvider.Theme.ToString()}',");
|
||||
builder.AppendLine($" branch: '{_configFileProvider.Branch.ToLower()}',");
|
||||
builder.AppendLine($" analytics: {_analyticsService.IsEnabled.ToString().ToLowerInvariant()},");
|
||||
builder.AppendLine($" userHash: '{HashUtil.AnonymousToken()}',");
|
||||
builder.AppendLine($" urlBase: '{_urlBase}',");
|
||||
builder.AppendLine($" isProduction: {RuntimeInfo.IsProduction.ToString().ToLowerInvariant()}");
|
||||
builder.AppendLine("};");
|
||||
builder.AppendLine("{");
|
||||
builder.AppendLine($" \"apiRoot\": \"{_urlBase}/api/v1\",");
|
||||
builder.AppendLine($" \"apiKey\": \"{_apiKey}\",");
|
||||
builder.AppendLine($" \"release\": \"{BuildInfo.Release}\",");
|
||||
builder.AppendLine($" \"version\": \"{BuildInfo.Version.ToString()}\",");
|
||||
builder.AppendLine($" \"instanceName\": \"{_configFileProvider.InstanceName.ToString()}\",");
|
||||
builder.AppendLine($" \"theme\": \"{_configFileProvider.Theme.ToString()}\",");
|
||||
builder.AppendLine($" \"branch\": \"{_configFileProvider.Branch.ToLower()}\",");
|
||||
builder.AppendLine($" \"analytics\": {_analyticsService.IsEnabled.ToString().ToLowerInvariant()},");
|
||||
builder.AppendLine($" \"userHash\": \"{HashUtil.AnonymousToken()}\",");
|
||||
builder.AppendLine($" \"urlBase\": \"{_urlBase}\",");
|
||||
builder.AppendLine($" \"isProduction\": {RuntimeInfo.IsProduction.ToString().ToLowerInvariant()}");
|
||||
builder.AppendLine("}");
|
||||
|
||||
_generatedContent = builder.ToString();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user