Creating localizatin .resx files makes empty .Designer.cs files










0














I'm trying to add localization to my .NET MVC project. As far as I've seen (here, here, and here), I should simply be able to create a total of three files (if I have two languages).



Resources.resx
Resources.en-us.resx
Resources.da-dk.resx


When I open the .resx files, I can add entries to them. Once I've done that (and set "Access Modifier" to either Internal or Public), it generates a Resources.*.Designer.cs file (as it should). However, for en-us and da-dk they are empty. No errors or anything.



As far as I could read (here, here, and here), I cannot have a dot between the file name and the .resx extension. And to my surprise, it's true. If I rename any of those en-us/da-dk files to Whatever.resx the Whatever.Designer.cs file will be created.



I've read a lot of answers, tried my way with T4 templates, and a bunch of other things, but I simply cannot get it to create a working Designer.cs file.



Am I doing it wrong? I feel like I've tried everything now. I just want to be able to do Resources.TestText and have my application do the translation depending on the culture.










share|improve this question





















  • I use a VS Extension called Resx Manager, which handles everything for you, you just install it and select the language you need and it creates all the files. It also has a UI to add the strings.
    – Nekeniehl
    Nov 13 '18 at 9:26










  • @Nekeniehl Doesn't really help me when the code doesn't work as expected. I created a new project and it works perfectly.
    – MortenMoulder
    Nov 13 '18 at 9:31










  • It was just a suggestion for next time, I always have struggle with localizations
    – Nekeniehl
    Nov 13 '18 at 10:01















0














I'm trying to add localization to my .NET MVC project. As far as I've seen (here, here, and here), I should simply be able to create a total of three files (if I have two languages).



Resources.resx
Resources.en-us.resx
Resources.da-dk.resx


When I open the .resx files, I can add entries to them. Once I've done that (and set "Access Modifier" to either Internal or Public), it generates a Resources.*.Designer.cs file (as it should). However, for en-us and da-dk they are empty. No errors or anything.



As far as I could read (here, here, and here), I cannot have a dot between the file name and the .resx extension. And to my surprise, it's true. If I rename any of those en-us/da-dk files to Whatever.resx the Whatever.Designer.cs file will be created.



I've read a lot of answers, tried my way with T4 templates, and a bunch of other things, but I simply cannot get it to create a working Designer.cs file.



Am I doing it wrong? I feel like I've tried everything now. I just want to be able to do Resources.TestText and have my application do the translation depending on the culture.










share|improve this question





















  • I use a VS Extension called Resx Manager, which handles everything for you, you just install it and select the language you need and it creates all the files. It also has a UI to add the strings.
    – Nekeniehl
    Nov 13 '18 at 9:26










  • @Nekeniehl Doesn't really help me when the code doesn't work as expected. I created a new project and it works perfectly.
    – MortenMoulder
    Nov 13 '18 at 9:31










  • It was just a suggestion for next time, I always have struggle with localizations
    – Nekeniehl
    Nov 13 '18 at 10:01













0












0








0







I'm trying to add localization to my .NET MVC project. As far as I've seen (here, here, and here), I should simply be able to create a total of three files (if I have two languages).



Resources.resx
Resources.en-us.resx
Resources.da-dk.resx


When I open the .resx files, I can add entries to them. Once I've done that (and set "Access Modifier" to either Internal or Public), it generates a Resources.*.Designer.cs file (as it should). However, for en-us and da-dk they are empty. No errors or anything.



As far as I could read (here, here, and here), I cannot have a dot between the file name and the .resx extension. And to my surprise, it's true. If I rename any of those en-us/da-dk files to Whatever.resx the Whatever.Designer.cs file will be created.



I've read a lot of answers, tried my way with T4 templates, and a bunch of other things, but I simply cannot get it to create a working Designer.cs file.



Am I doing it wrong? I feel like I've tried everything now. I just want to be able to do Resources.TestText and have my application do the translation depending on the culture.










share|improve this question













I'm trying to add localization to my .NET MVC project. As far as I've seen (here, here, and here), I should simply be able to create a total of three files (if I have two languages).



Resources.resx
Resources.en-us.resx
Resources.da-dk.resx


When I open the .resx files, I can add entries to them. Once I've done that (and set "Access Modifier" to either Internal or Public), it generates a Resources.*.Designer.cs file (as it should). However, for en-us and da-dk they are empty. No errors or anything.



As far as I could read (here, here, and here), I cannot have a dot between the file name and the .resx extension. And to my surprise, it's true. If I rename any of those en-us/da-dk files to Whatever.resx the Whatever.Designer.cs file will be created.



I've read a lot of answers, tried my way with T4 templates, and a bunch of other things, but I simply cannot get it to create a working Designer.cs file.



Am I doing it wrong? I feel like I've tried everything now. I just want to be able to do Resources.TestText and have my application do the translation depending on the culture.







c# .net localization resx






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 8:24









MortenMoulderMortenMoulder

2,59332154




2,59332154











  • I use a VS Extension called Resx Manager, which handles everything for you, you just install it and select the language you need and it creates all the files. It also has a UI to add the strings.
    – Nekeniehl
    Nov 13 '18 at 9:26










  • @Nekeniehl Doesn't really help me when the code doesn't work as expected. I created a new project and it works perfectly.
    – MortenMoulder
    Nov 13 '18 at 9:31










  • It was just a suggestion for next time, I always have struggle with localizations
    – Nekeniehl
    Nov 13 '18 at 10:01
















  • I use a VS Extension called Resx Manager, which handles everything for you, you just install it and select the language you need and it creates all the files. It also has a UI to add the strings.
    – Nekeniehl
    Nov 13 '18 at 9:26










  • @Nekeniehl Doesn't really help me when the code doesn't work as expected. I created a new project and it works perfectly.
    – MortenMoulder
    Nov 13 '18 at 9:31










  • It was just a suggestion for next time, I always have struggle with localizations
    – Nekeniehl
    Nov 13 '18 at 10:01















I use a VS Extension called Resx Manager, which handles everything for you, you just install it and select the language you need and it creates all the files. It also has a UI to add the strings.
– Nekeniehl
Nov 13 '18 at 9:26




I use a VS Extension called Resx Manager, which handles everything for you, you just install it and select the language you need and it creates all the files. It also has a UI to add the strings.
– Nekeniehl
Nov 13 '18 at 9:26












@Nekeniehl Doesn't really help me when the code doesn't work as expected. I created a new project and it works perfectly.
– MortenMoulder
Nov 13 '18 at 9:31




@Nekeniehl Doesn't really help me when the code doesn't work as expected. I created a new project and it works perfectly.
– MortenMoulder
Nov 13 '18 at 9:31












It was just a suggestion for next time, I always have struggle with localizations
– Nekeniehl
Nov 13 '18 at 10:01




It was just a suggestion for next time, I always have struggle with localizations
– Nekeniehl
Nov 13 '18 at 10:01












1 Answer
1






active

oldest

votes


















0














It is by design.



The Resources.EN-US.resx file types, doesn't have a designer because the actual designer is in it's "parent" file, Resources.EN-US.resx. The en-us file only holds the key/value XML.



If you are calling your Resource, you probably use it like:



var someVar = Resources.SomeLocalizedString;


You don't have to differentiate between the EN-US types.



If you look at the designer's code, you can see whats happening (hold on, I'll fetch an example)



So, you don't need those designers, and it should work out of the box if you set the culture info of the UI thread.



Thread.CurrentThread.CurrentUICulture = new CultureInfo("EN-US");





share|improve this answer




















  • That makes sense, if that was the case. But my locale is set to en-US (and I did try to uppercase the US and DK part), but it's not being affected in my code. I did add the <globalization /> tag inside my Web.config file
    – MortenMoulder
    Nov 13 '18 at 8:37










  • Ok, I'll spin up a visual studio: what kind of project are you working on? Console? Asp? Wpf?
    – Stefan
    Nov 13 '18 at 8:40










  • It's an ASP.NET Web Project. I did try setting the culture using a Thread in the Startup.cs, but it still won't use my translation (it just defaults to the Resource.resx value)
    – MortenMoulder
    Nov 13 '18 at 8:44










  • Ah, yes, I think I know whats happening: if you do a call to the asp.net web project, a new thread is spinned-up; this new thread contains the default UI culture info.
    – Stefan
    Nov 13 '18 at 8:46










  • If I output the Thread.CurrentThread.CurrentUICulture on the page, it shows en-US. So something is definitely not working haha
    – MortenMoulder
    Nov 13 '18 at 8:47










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53276695%2fcreating-localizatin-resx-files-makes-empty-designer-cs-files%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














It is by design.



The Resources.EN-US.resx file types, doesn't have a designer because the actual designer is in it's "parent" file, Resources.EN-US.resx. The en-us file only holds the key/value XML.



If you are calling your Resource, you probably use it like:



var someVar = Resources.SomeLocalizedString;


You don't have to differentiate between the EN-US types.



If you look at the designer's code, you can see whats happening (hold on, I'll fetch an example)



So, you don't need those designers, and it should work out of the box if you set the culture info of the UI thread.



Thread.CurrentThread.CurrentUICulture = new CultureInfo("EN-US");





share|improve this answer




















  • That makes sense, if that was the case. But my locale is set to en-US (and I did try to uppercase the US and DK part), but it's not being affected in my code. I did add the <globalization /> tag inside my Web.config file
    – MortenMoulder
    Nov 13 '18 at 8:37










  • Ok, I'll spin up a visual studio: what kind of project are you working on? Console? Asp? Wpf?
    – Stefan
    Nov 13 '18 at 8:40










  • It's an ASP.NET Web Project. I did try setting the culture using a Thread in the Startup.cs, but it still won't use my translation (it just defaults to the Resource.resx value)
    – MortenMoulder
    Nov 13 '18 at 8:44










  • Ah, yes, I think I know whats happening: if you do a call to the asp.net web project, a new thread is spinned-up; this new thread contains the default UI culture info.
    – Stefan
    Nov 13 '18 at 8:46










  • If I output the Thread.CurrentThread.CurrentUICulture on the page, it shows en-US. So something is definitely not working haha
    – MortenMoulder
    Nov 13 '18 at 8:47















0














It is by design.



The Resources.EN-US.resx file types, doesn't have a designer because the actual designer is in it's "parent" file, Resources.EN-US.resx. The en-us file only holds the key/value XML.



If you are calling your Resource, you probably use it like:



var someVar = Resources.SomeLocalizedString;


You don't have to differentiate between the EN-US types.



If you look at the designer's code, you can see whats happening (hold on, I'll fetch an example)



So, you don't need those designers, and it should work out of the box if you set the culture info of the UI thread.



Thread.CurrentThread.CurrentUICulture = new CultureInfo("EN-US");





share|improve this answer




















  • That makes sense, if that was the case. But my locale is set to en-US (and I did try to uppercase the US and DK part), but it's not being affected in my code. I did add the <globalization /> tag inside my Web.config file
    – MortenMoulder
    Nov 13 '18 at 8:37










  • Ok, I'll spin up a visual studio: what kind of project are you working on? Console? Asp? Wpf?
    – Stefan
    Nov 13 '18 at 8:40










  • It's an ASP.NET Web Project. I did try setting the culture using a Thread in the Startup.cs, but it still won't use my translation (it just defaults to the Resource.resx value)
    – MortenMoulder
    Nov 13 '18 at 8:44










  • Ah, yes, I think I know whats happening: if you do a call to the asp.net web project, a new thread is spinned-up; this new thread contains the default UI culture info.
    – Stefan
    Nov 13 '18 at 8:46










  • If I output the Thread.CurrentThread.CurrentUICulture on the page, it shows en-US. So something is definitely not working haha
    – MortenMoulder
    Nov 13 '18 at 8:47













0












0








0






It is by design.



The Resources.EN-US.resx file types, doesn't have a designer because the actual designer is in it's "parent" file, Resources.EN-US.resx. The en-us file only holds the key/value XML.



If you are calling your Resource, you probably use it like:



var someVar = Resources.SomeLocalizedString;


You don't have to differentiate between the EN-US types.



If you look at the designer's code, you can see whats happening (hold on, I'll fetch an example)



So, you don't need those designers, and it should work out of the box if you set the culture info of the UI thread.



Thread.CurrentThread.CurrentUICulture = new CultureInfo("EN-US");





share|improve this answer












It is by design.



The Resources.EN-US.resx file types, doesn't have a designer because the actual designer is in it's "parent" file, Resources.EN-US.resx. The en-us file only holds the key/value XML.



If you are calling your Resource, you probably use it like:



var someVar = Resources.SomeLocalizedString;


You don't have to differentiate between the EN-US types.



If you look at the designer's code, you can see whats happening (hold on, I'll fetch an example)



So, you don't need those designers, and it should work out of the box if you set the culture info of the UI thread.



Thread.CurrentThread.CurrentUICulture = new CultureInfo("EN-US");






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 8:33









StefanStefan

8,30873760




8,30873760











  • That makes sense, if that was the case. But my locale is set to en-US (and I did try to uppercase the US and DK part), but it's not being affected in my code. I did add the <globalization /> tag inside my Web.config file
    – MortenMoulder
    Nov 13 '18 at 8:37










  • Ok, I'll spin up a visual studio: what kind of project are you working on? Console? Asp? Wpf?
    – Stefan
    Nov 13 '18 at 8:40










  • It's an ASP.NET Web Project. I did try setting the culture using a Thread in the Startup.cs, but it still won't use my translation (it just defaults to the Resource.resx value)
    – MortenMoulder
    Nov 13 '18 at 8:44










  • Ah, yes, I think I know whats happening: if you do a call to the asp.net web project, a new thread is spinned-up; this new thread contains the default UI culture info.
    – Stefan
    Nov 13 '18 at 8:46










  • If I output the Thread.CurrentThread.CurrentUICulture on the page, it shows en-US. So something is definitely not working haha
    – MortenMoulder
    Nov 13 '18 at 8:47
















  • That makes sense, if that was the case. But my locale is set to en-US (and I did try to uppercase the US and DK part), but it's not being affected in my code. I did add the <globalization /> tag inside my Web.config file
    – MortenMoulder
    Nov 13 '18 at 8:37










  • Ok, I'll spin up a visual studio: what kind of project are you working on? Console? Asp? Wpf?
    – Stefan
    Nov 13 '18 at 8:40










  • It's an ASP.NET Web Project. I did try setting the culture using a Thread in the Startup.cs, but it still won't use my translation (it just defaults to the Resource.resx value)
    – MortenMoulder
    Nov 13 '18 at 8:44










  • Ah, yes, I think I know whats happening: if you do a call to the asp.net web project, a new thread is spinned-up; this new thread contains the default UI culture info.
    – Stefan
    Nov 13 '18 at 8:46










  • If I output the Thread.CurrentThread.CurrentUICulture on the page, it shows en-US. So something is definitely not working haha
    – MortenMoulder
    Nov 13 '18 at 8:47















That makes sense, if that was the case. But my locale is set to en-US (and I did try to uppercase the US and DK part), but it's not being affected in my code. I did add the <globalization /> tag inside my Web.config file
– MortenMoulder
Nov 13 '18 at 8:37




That makes sense, if that was the case. But my locale is set to en-US (and I did try to uppercase the US and DK part), but it's not being affected in my code. I did add the <globalization /> tag inside my Web.config file
– MortenMoulder
Nov 13 '18 at 8:37












Ok, I'll spin up a visual studio: what kind of project are you working on? Console? Asp? Wpf?
– Stefan
Nov 13 '18 at 8:40




Ok, I'll spin up a visual studio: what kind of project are you working on? Console? Asp? Wpf?
– Stefan
Nov 13 '18 at 8:40












It's an ASP.NET Web Project. I did try setting the culture using a Thread in the Startup.cs, but it still won't use my translation (it just defaults to the Resource.resx value)
– MortenMoulder
Nov 13 '18 at 8:44




It's an ASP.NET Web Project. I did try setting the culture using a Thread in the Startup.cs, but it still won't use my translation (it just defaults to the Resource.resx value)
– MortenMoulder
Nov 13 '18 at 8:44












Ah, yes, I think I know whats happening: if you do a call to the asp.net web project, a new thread is spinned-up; this new thread contains the default UI culture info.
– Stefan
Nov 13 '18 at 8:46




Ah, yes, I think I know whats happening: if you do a call to the asp.net web project, a new thread is spinned-up; this new thread contains the default UI culture info.
– Stefan
Nov 13 '18 at 8:46












If I output the Thread.CurrentThread.CurrentUICulture on the page, it shows en-US. So something is definitely not working haha
– MortenMoulder
Nov 13 '18 at 8:47




If I output the Thread.CurrentThread.CurrentUICulture on the page, it shows en-US. So something is definitely not working haha
– MortenMoulder
Nov 13 '18 at 8:47

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53276695%2fcreating-localizatin-resx-files-makes-empty-designer-cs-files%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

27

Top Tejano songwriter Luis Silva dead of heart attack at 64

Category:Rhetoric