title: ASP NET 5 Localization using View components in a separate assembly
body: <p>I have a "Class Library" project with some "ViewComponents" on it and I already made them work on my "MVC 6 Web app" (<a href="https://stackoverflow.com/questions/34236850/asp-net-mvc-6-view-components-in-a-separate-assembly">thanks to this question</a>) but now I'm trying to add language resources (localization) to my "ViewComponents". Any suggestion on how this should be done?.</p>
  
  <p>I already added the necesary lines to the startup file on my "MVC 6 Web app":</p>
  
  <p><strong>startup.cs</strong></p>
  
  <pre><code>[...]
  services.AddMvc()
          .AddViewLocalization(options =&gt; options.ResourcesPath = "Resources");
  [...]
  app.UseRequestLocalization(new RequestCulture(new CultureInfo("es-MX")));
  </code></pre>
  
  <p>Also I added the dependencies on my "Class Library" Views:</p>
  
  <p><strong>Views/Shared/Components/Header/foo.cshtml</strong></p>
  
  <pre><code>@using Microsoft.AspNet.Mvc.Localization
  @inject IViewLocalizer LocString
  &lt;h1&gt;@LocString["HelloWorld"]&lt;/h1&gt;
  </code></pre>
  
  <p>and created the Resource folder and file in my "Class Library" project:</p>
  
  <pre><code>-Resources
     -Views.Shared.Components.Header.foo.cshtml.resx
  </code></pre>
  
  <p>but all I get is the name of the key "HelloWorld" instead of the localized resource "Hola mundo"</p>
  
  <p>In short Am I missing something? Does anyone knows a way to use localized resources in "view components" from a "class library" on a "mvc 6 web app" </p>
  
  <p>Notes:</p>
  
  <ul>
  <li><p>I'm using mvc 6 RC1</p></li>
  <li><p>Resources from other views that are not ViewComponents are working fine.</p></li>
  </ul>
  
  <p>Thank you!</p>