0

I have a winform, C# application that I would like to have run in localised languages. The target .Net is 3.0 as a lot of my users are still using XP. The application is a system tray application.

I have put all the strings into a Resources.resx and have generated Resources.XX.resx files for the different languages I need, using ResX Resource Manager.

If I set the CurrentUICulture to another language (i.e. Finnish) using the code:

Thread.CurrentThread.CurrentUICulture = new CultureInfo("fi-FI");

It works as expected and shows all the forms in Finnish.

However if I install the application on a machine with the Language set as Finnish all of the winforms come up with te English strings (English is also the neutral string)

I have checked that the forms have the property localizable set to true.


Why does it work for when I hardcode the CurrentUICulture but not when I don't?

Is there an alternative way to check the UI language of the PC and update the application CurrentUICulture?

Luke
  • 1,077
  • 13
  • 33
  • Make sure the satellite assemblies are deployed near the application on client machines. – Reza Aghaei Sep 23 '16 at 03:44
  • If you set the `Thread.CurrentThread.CurrentUICulture` to `new CultureInfo("fi-FI")` What does it mean: *Why does it work for when I hardcode the `CurrentUICulture` but not when I don't?* – Reza Aghaei Sep 23 '16 at 03:47
  • I test on my development PC by typing in: Thread.CurrentThread.CurrentUICulture = new CultureInfo("fi-FI"); at the start of program.cs However when I remove the above line and putting on a PC running in Finnish, the text appears in English. – Luke Sep 23 '16 at 03:57
  • When you say *on a PC running in Finnish* do you mean the OS language is Finnish or just the user have Finnish in it's keyboard languages? Does the whole windows is in Finnish? – Reza Aghaei Sep 23 '16 at 04:34
  • @RezaAghaei The PC display language was changed to Finnish in windows Open Region and Language -> Keyboards and Languages -> Display language. – Luke Sep 23 '16 at 04:53
  • I tested an application which used uad `fa-IR` and `en-US` resources on a machine with default `fa-IR` OS UI Language. It worked properly without need to any specific code. I just used `MesssageBox.Show(Properties.Resources.Test);` in click event of a `Button` and it showed the Persian text after execution. – Reza Aghaei Sep 23 '16 at 10:19
  • If you're sure the client machine OS UI Language is `fi-FI` then you can use `Properties.Resources.Culture = System.Globalization.CultureInfo.CurrentUICulture;` at start-up of your application. It changes the `Properties.Resources.Culture` to `fi-FI` and then changing `Thread.CurrentThread.CurrentUICulture` doesn't have any impact on the resource values like `Properties.Resources.Test`. – Reza Aghaei Sep 23 '16 at 10:23
  • It appears the issues was some settings with my MVS. The folder which contained the application.resources.dll for each language wasnt being generated in the bin/release folder. So it was not put in NSIS installer and not carried across to the Finnish PC. The application.resources.dll was succesfully generated in the debug file, which was why it succesfully worked on the dev PC. – Luke Sep 26 '16 at 05:31
  • It's the first thing which I usually check, like I said in the first comment. – Reza Aghaei Sep 26 '16 at 06:50

1 Answers1

1

enter image description here You can set Locate and Language on form, It will display by language of windows

D T
  • 3,522
  • 7
  • 45
  • 89
  • Hi @DT, thanks for your answer + 1. I have already selected these. To implement this way will mean I will have to update each forms resx separately? Am I right? Currently I am trying to have one resx under properties as there are a number of strings used in multpile forms to minimise translations. Doing it the way in your answer would require the maintenance of around 5 resx folders as opposed to one. – Luke Sep 23 '16 at 04:12
  • Is there a way to get the form.resx to reference the resources.resx files? Or change the form referencing so it references resources.resx instead of form.resx? – Luke Sep 23 '16 at 04:24