NeutralResourcesLanguageAttribute Doesn't Respect Localization in ASP.NET Core

Nov 06, 2016     Viewed 1403 times    2 Comments
Posted in #Localization  #Tips & Tricks 

I have written many localization blog posts in ASP.NET because I like it :). While I was working in localization repo and trying to help people to fix their issue, I notice that there 're many folks facing a strange issue while they are localize their web applications. The issue is the localization APIs are using the default culture even they are specifying another culture while application is running?!!

I would like to say for those folks if you come up with such situation, please check your code and the order of the middleware first. Then check you if you already set the language attribute in the project.json as the following:

  "language": "fr-FR",
  "version": "1.1.0-*",
  "dependencies": {
    "Microsoft.AspNetCore.Localization": "1.1.0-*",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*",
    "Microsoft.Extensions.Configuration.CommandLine": "1.1.0-*",
    "Microsoft.Extensions.Localization": "1.1.0-*"
  "buildOptions": {
    "emitEntryPoint": true
  "publishOptions": {
    "include": [
  "frameworks": {
    "net451": {},
    "netcoreapp1.1": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "version": "1.1.0-*",
          "type": "platform"
  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*"
  "scripts": {
    "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"

"language": "fr-FR" setting this attribute may causes a critical issue if you didn't aware, because this attribute is set the NeutralResourcesLanguageAttribute behind the scene. Basically it will do exactly what the next line did.


For those who don't know the NeutralResourcesLanguageAttribute this attribute informs the ResourceManager of an application's default culture. Of course this is a critical issue, because if this property is set for a certain culture for example French (fr-FR), so when the ResourceManager trying to lookup for the resource file it will look for Resource.resx instead of What that means?!! IF you already set the default culture using the localization APIs with non French one for example English (en-US). The ResourceManager will look for the same resource file for both culture, this is the main issue :(

My advice is try to avoid setting language attribute in project.json or setting NeutralResourcesLanguageAttribute unless it is match the default culture that you 're setting in the localization APIs, otherwise you will be in trouble.

Finally hope this post give you a tip of how can simple attribute affect the entire application, if we don't know what exactly doing behind the scene.

Twitter Facebook Google + LinkedIn


David (11/29/2016 6:12:48 AM)

Hi! If you are involved in the process of localizing your software application, I recommend using a collaborative translation management platform like It has a flexible and friendly UI and lots of useful features: API, translation memory, GitHub and Bitbucket integration, WordPress plugin that will speed up the localization process.

Hisham Bin Ateya (12/1/2016 9:05:02 PM)

@David I'm not talking about localization process, I just showed you the NeutralResourcesLanguageAttribute issue with Localization in ASP.NET Core

Leave a Comment