在下面的程序中,为了获得资源字符串,我使用了_localizer"About Title“,其中"About Title”是一个神奇的字符串。如何避免使用这样的字符串?有没有强类型的方法?
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Localization;
namespace Localization.StarterWeb.Controllers
{
[Route("api/[controller]")]
public class AboutController :
我在控制器中使用'IStringLocalizer'来在我的网站上定位静态数据!()
但是,本地化实体(如NewsEntity或PostEntity )的最佳方法是什么?或者如何编码可本地化的实体?
public class News : BaseEntity
{
public string Title { get; set; }
public string Body { get; set; }
}
或
{Joking}
public class News : BaseEntity
{
public string TitleEn { get; se
我创建了一个空项目。
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddLocalization(s => s.ResourcesPath = "Resources");
var supportedCultures = new CultureInfo[]
{
new CultureInfo("de-CH"),
new CultureInfo("en-GB"),
在尝试本地化我的应用程序时,我遵循了以下步骤:
这是我的代码:
Startup.cs
public List<IRequestCultureProvider> RequestCultureProviders { get; private set; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.
我试图在IStringLocalizer核心1.1中创建一个asp.net嵌入,以便在整个项目中使用每种语言的单个资源文件(而不是每页一种语言.)。我也找不到如何在这里获得请求语言来返回具有良好文化的值。
我可能在实现它的方式上迷失了方向,但是文档在这个问题上非常糟糕。有人可以告诉我如何在这里获得良好的文化(用户的一种eq请求用户语言):
public class CustomLocalizer : IStringLocalizer
{
private readonly CultureInfo _currentCulture;
public IEnumerable<