-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocalizationController.cs
36 lines (31 loc) · 1.15 KB
/
LocalizationController.cs
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
36
using GenericClassLocalization.Localization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Localization;
namespace GenericClassLocalization.Controllers;
[ApiController]
[Route("[controller]")]
public class LocalizationController : Controller
{
private readonly IStringLocalizer<MyClass<int, string>> _myClassLocalizer;
private readonly IStringLocalizer<MyClass<int, double>.MySubClass<string, int>> _mySubClassLocalizer;
public LocalizationController(IStringLocalizer<MyClass<int, string>> myClassLocalizer,
IStringLocalizer<MyClass<int, double>.MySubClass<string, int>> mySubClassLocalizer)
{
_myClassLocalizer = myClassLocalizer;
_mySubClassLocalizer = mySubClassLocalizer;
}
[HttpGet(nameof(HelloWorld))]
public IActionResult HelloWorld()
{
return Ok(new Messages
{
MyClassMessage = _myClassLocalizer["HelloWorld"],
MySubClassMessage = _mySubClassLocalizer["HelloWorld"]
});
}
private class Messages
{
public string MyClassMessage { get; set; } = default!;
public string MySubClassMessage { get; set; } = default!;
}
}