title: ASP.NET Core Localization with help of SharedResources
body: <p>Hi I have a question about the SharedResources file. It is glanced over in the tutorial here: <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization" rel="noreferrer"><a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization" rel="noreferrer">https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization</a></a>, and I'm not sure if I get it correctly.</p>
  
  <p>I am supposed to create a <code>SharedResources.cs</code> class, but where should i put it and should it be empty or do I need to fill it with some data?</p>
  
  <p>Same goes for the resource file, should I create a <code>SharedResources.da.resx</code> file and put all my shared strings there? Where should it go?</p>
  
  <p>And when I use <code>IHtmlLocalizer&lt;SharedResources&gt;</code> do I just write <code>@using</code> and point it to the namespace where <code>SharedResources.cs</code> resides?</p>
  
  <p>I tried putting <code>SharedResources.cs</code> and <code>SharedResources.da.resx</code> in the Resources folder and use it to change website language to Danish, but it does not work. Using dedicated Resource file like <code>Index.da.resx</code> and <code>IViewLocalizer</code> works fine, but <code>IHtmlLocalizer&lt;SharedResources&gt;</code> does not seem to work.</p>
  
  <p>When I looked at the example project linked to at the bottom of the page I didn't find any place where SharedResources is used, it would be great if somebody updated it with an example of that.</p>
  
  <p>Here's how I tried to do it:</p>
  
  <p>Views/Home/Index.cshtml:</p>
  
  <pre><code>@using Funkipedia.Resources
  @using Microsoft.AspNetCore.Mvc.Localization
  @inject IHtmlLocalizer&lt;Shared&gt; SharedLocalizer
  ...
  &lt;p&gt;@SharedLocalizer["Hei"]&lt;/p&gt;
  ...
  </code></pre>
  
  <p>At top of ConfigureServices in Startup.cs:</p>
  
  <pre><code>services.AddLocalization(options =&gt; options.ResourcesPath = "Resources");
  services.AddMvc()
    .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
    .AddDataAnnotationsLocalization();
  </code></pre>
  
  <p>At top of Configure in Startup.cs:</p>
  
  <pre><code>var supportedCultures = new List&lt;CultureInfo&gt;
  {
         new CultureInfo("nb-NO"),
         new CultureInfo("sv-SE"),
         new CultureInfo("da-DK")
  };
  
  app.UseRequestLocalization(new RequestLocalizationOptions
  {
         DefaultRequestCulture = new RequestCulture("nb-NO"),
         SupportedCultures = supportedCultures,
         SupportedUICultures = supportedCultures
  });
  </code></pre>
  
  <p>Resources folder contains empty class called <code>Shared.cs</code> and <code>Shared.da.resx</code> which contains shared strings. Do I maybe need to change the name of it to <code>SharedResources.cs</code> and <code>SharedResources.da.resx</code>?</p>