1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-03-05 13:20:20 -05:00

Add v5 Language endpoints

This commit is contained in:
Mark McDowall
2026-02-14 12:13:51 -08:00
parent d8698d1c28
commit 236978a9b1
2 changed files with 47 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
using Microsoft.AspNetCore.Mvc;
using NzbDrone.Core.Languages;
using Sonarr.Http;
using Sonarr.Http.REST;
namespace Sonarr.Api.V5.Localization;
[V5ApiController]
public class LanguageController : RestController<LanguageResource>
{
protected override LanguageResource GetResourceById(int id)
{
var language = (Language)id;
return new LanguageResource
{
Id = (int)language,
Name = language.ToString()
};
}
[HttpGet]
public List<LanguageResource> GetAll()
{
var languageResources = Language.All.Select(l => new LanguageResource
{
Id = (int)l,
Name = l.ToString()
})
.OrderBy(l => l.Id > 0).ThenBy(l => l.Name)
.ToList();
return languageResources;
}
}

View File

@@ -0,0 +1,12 @@
using System.Text.Json.Serialization;
using Sonarr.Http.REST;
namespace Sonarr.Api.V5.Localization;
public class LanguageResource : RestResource
{
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public new int Id { get; set; }
public string? Name { get; set; }
public string? NameLower => Name?.ToLowerInvariant();
}