Resource file code not generated
Asked Answered
E

3

19

I have my default resource file Resources.resx for which visual studio nicely generates a designer.cs class, but when I try to create Resources.de-DE.resx, it does not generate.

I checked all the properties for both files are same.

It does generate for Resources1.resx, but not for Resources.de-DE.resx or Resources.en-US.resx.

Eventuate answered 30/7, 2013 at 9:1 Comment(2)
designer.cs isn't created by the resx, its created by visual studio along with the class file for the dialog (user control). What are you trying to accomplish? When the program runs, it will look for the correct string in the local resx, if it fails, it will look in the default resxChacha
I have a same problem. If I create the Resources.resx, code in Resources.Designer.resx generates. But, if rename file first file to Resources.en.resx, it doesn't.Bronchial
A
13

hello @TRS you may be confused about that there is a Designer.cs present For Resources.resx and there should be someDesigner.cs for Resources.de-DE.resx but this is not the case because designer file would be same for all the resource files. and also the property that is created in Designer.cs is also common that means you will use this property for every conversion so the difference that you can make is on the basis of ResourceCulture.

Arouse answered 30/7, 2013 at 11:5 Comment(1)
This helped me find out why I didn't have a resource-class when I didn't provide a default resource file.Quentinquercetin
C
5

Yes, Designer resx file remains empty. you should follow the below steps, it will work 100%. 1) Create Resource.resx file under any folder

2) set CustomTools = PublicResXFileCodeGenerator and Build Action = Embedded Resource in Resource.resx file property.

3) Now create the different language files like below, Resources.en-US.resx Resources.nl-NL.resx etc

4)If MVC, in your MVC Model refer this namespace as project.folder

5) change the one of the property as below (example)

 [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MMM/yyyy}"), Display(Name = "dtMovinDate",ResourceType = typeof(Resources.Resource))]
            public DateTime dtMovinDate { get; set; }

6)

 In config file add this under System.web

    <globalization enableClientBasedCulture="true" culture="en-US" uiCulture="en-US" />

7) rebuild the project and test it.

It will work. The real reason of designer.cs file empty is resource designer.cs will refer these files based on your web.config file.

Coadunate answered 28/6, 2017 at 10:3 Comment(1)
Step 2 solved my problem as the key values of the resource file were not accessible in the asp.net pages and now they are acessible. ThanksSorgo
D
5

Interestingly, I had similar situation today. I will share the scenario and solution here because I think it's related to your question.

I wanted to have a resource file for Arabic culture only, SharedResources.ar.resx, and I don't have another resource called SharedResources.resx.

The solution was to create the resource file with single [dot] in it, then rename it.

For example, in my case, I created the file with this name, SharedResources-ar.resx. Then double click and change its access modifier to public using the editor, like this:

enter image description here

This will generate .cs file with the correct static properties. After that, rename the file to the correct format. SharedResources.ar.resx. Otherwise it will not be generated!

I don't know if it's a good solution, but solve my problem and hope to solve someone's else too.

Dani answered 17/3, 2020 at 5:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.