localization - Understanding Resource files in MVC6 RC1 -


i've been trying wrap head around on how best implement resource files multiple languages in mvc6 due changes every release has me bit confused on how implement them properly. required , constraints?

a few articles i've looked at:

https://damienbod.com/2015/10/21/asp-net-5-mvc-6-localization/

mvc 6 : how use resx files?

http://pratikvasani.github.io/archive/2015/12/25/mvc-6-localization-how-to/

i'm trying set resource files have english , german available users, either based on browser settings or personal setting within account.

what best way of achieving this?

thanks in advance!

edit:

so per article, i've added following code startup.cs:

        services.addlocalization(options =>                 options.resourcespath = "resources");         services.addmvc()                 .addviewlocalization(microsoft.aspnet.mvc.razor.languageviewlocationexpanderformat.suffix)                 .adddataannotationslocalization();          var supportedcultures = new[]         {             new cultureinfo("de-de"),             new cultureinfo("en-us")         };          //set default localization culture         app.userequestlocalization(new requestlocalizationoptions         {             supportedcultures = supportedcultures,             supporteduicultures = supportedcultures         }, new requestculture(new cultureinfo("en-us"))); 

then within resources folder created new resx files file names:

  • "views.shared._localizationtest.en-us.resx"

  • "views.shared._localizationtest.de-de.resx"

and partial view looks like:

@using microsoft.aspnet.localization @using microsoft.aspnet.mvc.localization @inject iviewlocalizer localizer  <div>      @localizer["teststring"] </div> 

i still seem missing getting "teststring" show instead of "test string" english or "german: test string" (as per resource files).

any ideas?

the asp.net core default approach not have default language strings in resource file, have them wrapped in code. write app using english strings wrapped in localizer, , have 1 german resource file. see article https://docs.microsoft.com/aspnet/core/fundamentals/localization


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -