title: ASP.Net Core incomplete localization - Resolved Language
body: <p>In a ASP.Net Core web application with <strong>localization files not available to all pages, how can I know the finally resolved language?</strong></p>
  <p>I would like to localize some parts of my ASP.Net Core web application, leaving others in the default language, or a subset of languages. When I provide translations .Net Core just translates the pages, and when I don't .Net Core just serves the default language, which is the behavior I need.</p>
  <p>My problem comes when <strong>I need to know the resolved language</strong> to fill in the <code>HTML5</code> <code>lang</code> attribute in the Razor Pages, so my generated web page is correctly formatted.</p>
  <p><a href="https://stackoverflow.com/a/22513715/8150874">I found this solution:</a></p>
  <pre><code>lang=&quot;@System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName&quot;&gt;
  </code></pre>
  <p>But does not work in my scenario, because the thread language will be &quot;resolved correctly&quot; to the supported localization defined in <code>Startup.cs</code>, but as I am missing the localization file, the final localization used will be the default one, not updating the thread's <code>CurrentUICulture</code>.</p>
  <p>With <code>CurrentThread.CurrentUICulture</code> I'm wrongly serving English pages with a <code>lang</code> attribute filled with one of the &quot;supported&quot; languages.</p>
  <p><strong>How can I know the resolved language if no localization file is available?</strong></p>
  <p>Thank you very much.</p>