forked from modlist-org/KeyViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLanguageController.cs
More file actions
35 lines (34 loc) · 1.07 KB
/
LanguageController.cs
File metadata and controls
35 lines (34 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using JSON;
using KeyViewer.WebAPI.Core;
using Microsoft.AspNetCore.Mvc;
namespace KeyViewer.WebAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class LanguageController : ControllerBase
{
public enum Lang
{
Korean = 0,
English = 792770263,
Chinese = 1604051230,
Japanese = 234788714,
Vietnamese = 1191957691
}
public static SpreadSheet KTS = new SpreadSheet("1EiWVds23-gZeRCrXL-UYr-o-sc0m-jfqWa-G7qmUYdI");
public static Dictionary<Lang, string> sheetsJson = new Dictionary<Lang, string>();
[HttpGet("{lang}")]
public async Task<string> Get(Lang lang)
{
if (!sheetsJson.TryGetValue(lang, out var json))
{
var dict = await KTS.Download((int)lang);
JsonNode node = JsonNode.Empty;
foreach (var item in dict)
node[item.Key] = item.Value;
sheetsJson[lang] = json = node.ToString();
}
return json;
}
}
}