title: Localizaion using Resource file in .Net Core for different Culture
body: <p>I am working on .Net Core application and I wanted to implement Localization based on Culture info using Resource files for different culture.</p>
  
  <p>I have created Resource files for English and German culture as below:</p>
  
  <p><a href="https://i.stack.imgur.com/jhc8c.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jhc8c.jpg" alt="enter image description here"></a></p>
  
  <p>And also I have setup few things and set Default culture and German (de-DE) in Startup.cs as below : </p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
      {
          // Add framework services.
          services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
              options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
  
          services.AddIdentity&lt;ApplicationUser, IdentityRole&gt;()
              .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;()
              .AddDefaultTokenProviders();
          services.Configure&lt;RequestLocalizationOptions&gt;(
      opts =&gt;
      {
          var supportedCultures = new List&lt;CultureInfo&gt;
          {
              new CultureInfo("en-US"),
              new CultureInfo("de-DE"),
          };
          opts.DefaultRequestCulture = new RequestCulture(culture: "de-DE", uiCulture: "de-DE");
          // Formatting numbers, dates, etc.
          opts.SupportedCultures = supportedCultures;
          // UI strings that we have localized.
          opts.SupportedUICultures = supportedCultures;
      });
          services.AddLocalization(opts =&gt; { opts.ResourcesPath = "Localization"; });
          //services.AddMvc();
          services.AddMvc()
      .AddViewLocalization(
          LanguageViewLocationExpanderFormat.Suffix,
          opts =&gt; { opts.ResourcesPath = "Localization"; })
      .AddDataAnnotationsLocalization();
          // Add application services.
      }
  </code></pre>
  
  <p>Also below :</p>
  
  <pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
      {
          loggerFactory.AddConsole(Configuration.GetSection("Logging"));
          loggerFactory.AddDebug();
  
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
              app.UseDatabaseErrorPage();
              app.UseBrowserLink();
          }
          else
          {
              app.UseExceptionHandler("/Home/Error");
          }
  
          app.UseStaticFiles();
  
          var options = app.ApplicationServices.GetService&lt;IOptions&lt;RequestLocalizationOptions&gt;&gt;();
          app.UseRequestLocalization(options.Value);
  
          app.UseIdentity();
  
          // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715
  
          app.UseMvc(routes =&gt;
          {
              routes.MapRoute(
                  name: "default",
                  template: "{controller=Home}/{action=Index}/{id?}");
          });
      }
  </code></pre>
  
  <p>Also I have configure below in web.config file</p>
  
  <pre><code> &lt;system.web&gt;
  &lt;globalization enableClientBasedCulture="true" culture="de-DE" uiCulture="de-DE" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>And in the view file I have added this in the top :</p>
  
  <pre><code>@using Microsoft.AspNetCore.Mvc.Localization
  @inject IViewLocalizer Localizer
  </code></pre>
  
  <p>And I wanted to display Localize value in Label as below:</p>
  
  <pre><code>&lt;lable&gt;@EmailService.Web.Localization.Resource.AddNewTemplate&lt;/lable&gt;
  </code></pre>
  
  <p>But here I was always geting value from Default Resource file i.e. Resource.resx and from Resource.de-DE.resx.</p>
  
  <p>Here is the two resource files value</p>
  
  <p><a href="https://i.stack.imgur.com/4blC3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4blC3.jpg" alt="enter image description here"></a></p>
  
  <p>German resource file and its value</p>
  
  <p><a href="https://i.stack.imgur.com/YSD8e.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YSD8e.jpg" alt="enter image description here"></a></p>
  
  <p>So here, My problem is, I am always getting value from english resource file and not from German resource file.</p>
  
  <p>So, how can I set German culture and get value from German resource file.</p>
  
  <p>Please help me.... Thanks.</p>