4

I created a simple console application to display "Hello World" string. Later I brought in resource files to support different languages and put the translated version of "Hello World". I try to run the console.exe in chinese OS and expecting to see "Hello World" to be displayed in chinese. Unfortunately it's displaying english.

After analysis, found that adding .resx files creates a separate folder in the project with .resource dll for each language (sattellite assembly). So, if i place the .exe along with other folders and run, then "Hello World" displayed in chinese. If I remove the folders (.resource) and then run only .exe, then again it displays "Hello World" in english.

Is there a way to create an .exe with all the resource files mapped together. So that I need not place the folders along with .exe before running the .exe.

By the way, i'm trying to access the strings using Strings.STRING_NAME where "Strings" is the name of the default resource file. String files of other languages are of type Strings.fr.resx, Strings.de.resx.

Please help in this regard.

Thanks in advance.

user3220129
  • 503
  • 9
  • 24
  • This seems to have solutions: http://stackoverflow.com/questions/1453755/how-to-embed-a-satellite-assembly-into-the-exe-file – Knerd Feb 24 '14 at 14:33
  • I am curious. What problem is this meant to solve? What benefit do you get from compiling all of tje assemblies into one file? – Gusdor Feb 24 '14 at 14:36
  • Hi Gusdor, the main problem is to have a single .exe deployed in a remote machine which diplays localized messages. – user3220129 Feb 24 '14 at 14:39
  • One workaround tried is to publish the console application, thereby a setup.exe would be created with necessary translated files. Running the setup.exe resolved the issue. But, I'm not sure whether this is a right approach. Please guide me in this regard. – user3220129 Feb 24 '14 at 19:00

3 Answers3

0

The solution is here:

https://stackoverflow.com/a/1955060/1028323 ( Single-assembly multi-language Windows Forms deployment (ILMerge and satellite assemblies / localization) - possible? )

Community
  • 1
  • 1
Only a Curious Mind
  • 2,807
  • 23
  • 39
0

These extra assemblies are called Satellte assemblies. They are kept separate so that you do not have to deploy all of then languages if you only need a some.

From Introduction to Satellite Assemblies;

By definition, satellite assemblies do not contain code, except for that which is auto generated. Therefore, they cannot be executed as they are not in the main assembly. However, note that satellite assemblies are associated with a main assembly that usually contains default neutral resources (for example, en-US). A big benefit is that you can add support for a new culture or replace/update satellite assemblies without recompiling or replacing the application’s main assembly.

Gusdor
  • 14,001
  • 2
  • 52
  • 64
0

I am a little bit confused about what you are doing to get the problem with the currently selected culture.

Are you aware that you somehow need to set the culture first to be sure, that the one that you want to have is currently used? So you need to do something like this:

     System.Threading.Thread.CurrentThread.CurrentUICulture = new   System.Globalization.CultureInfo("en-US");
     System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");