aspnet.core localization cannot make it work

▼魔方 西西 提交于 2019-12-08 13:41:30

问题


It must be obvious only I cannot see the problem. I am banging my head against the wall for 6 hours now.

I am trying to use localization in an aspnet.core 2.0.6 webapp. The packages I have:

  • Microsoft.AspNetCore.All 2.0.6
  • Microsoft.Extensions.Localization 2.0.3

I initialized it properly using:

 services.AddLocalization(options => options.ResourcesPath = "Resources");

in Startup.ConfigureServices (first line)

app.UseRequestLocalization(options => ...) 

in Startup.Configure (first line)

I have a dummy SharedResources class in the project root (namespace is identical to assembly name). I also have Resources/SharedResources.xy.resx files.

I inject IStringLocalizer<SharedResources> into controller. The culture is set properly. My translation code is:

var test = _localizer.GetString("Test");
test = _localizer.WithCulture(CultureInfo.GetCultureInfo("xy")).GetString("Test");

I get the original string back. I do not get any kind of error messages on console except one information:

Loaded '/app/bin/Debug/netcoreapp2.0/xy/AssemblyName.resources.dll'. Module was built without symbols.

Where xy is the culture code I used and AssemblyName is the name of my web app. This is a quite big project and runs under docker in my environment however, I assume that should not be a problem.

I could not find any information about debugging or tracing the localization middleware. Is it possible? What can be the next step in order to figure out what is going on? I ran out of ideas.

Thanks in advance!

来源:https://stackoverflow.com/questions/54914990/aspnet-core-localization-cannot-make-it-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!