aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Controllers/Testing
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-10-25 18:46:01 +0800
committerGitHub <noreply@github.com>2019-10-25 18:46:01 +0800
commita175f8328d7a6c36464676d54fc50d03e64be0af (patch)
treec6ec0a916c78a02b36113fb62f0e919019df6cfc /Timeline/Controllers/Testing
parent681e2cc9ecaeefd883a7c6645374926c184fba5d (diff)
parent5790142f81f2a94ad073834b1534acbf9b02ea3c (diff)
downloadtimeline-a175f8328d7a6c36464676d54fc50d03e64be0af.tar.gz
timeline-a175f8328d7a6c36464676d54fc50d03e64be0af.tar.bz2
timeline-a175f8328d7a6c36464676d54fc50d03e64be0af.zip
Merge pull request #52 from crupest/i18n
Add NeutralResourcesLanguage. Conform to best practices.
Diffstat (limited to 'Timeline/Controllers/Testing')
-rw-r--r--Timeline/Controllers/Testing/TestingI18nController.cs36
1 files changed, 36 insertions, 0 deletions
diff --git a/Timeline/Controllers/Testing/TestingI18nController.cs b/Timeline/Controllers/Testing/TestingI18nController.cs
new file mode 100644
index 00000000..febb56a5
--- /dev/null
+++ b/Timeline/Controllers/Testing/TestingI18nController.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Localization;
+
+// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
+
+namespace Timeline.Controllers.Testing
+{
+ [Route("testing/i18n")]
+ [ApiController]
+ public class TestingI18nController : Controller
+ {
+ private readonly IStringLocalizer<TestingI18nController> _stringLocalizer;
+
+ public TestingI18nController(IStringLocalizer<TestingI18nController> stringLocalizer)
+ {
+ _stringLocalizer = stringLocalizer;
+ }
+
+ [HttpGet("direct")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1822:Mark members as static")]
+ public ActionResult<string> Direct()
+ {
+ return Resources.Controllers.Testing.TestingI18nController.TestString;
+ }
+
+ [HttpGet("localizer")]
+ public ActionResult<string> Localizer()
+ {
+ return _stringLocalizer["TestString"].Value;
+ }
+ }
+}