Click here to Skip to main content
Click here to Skip to main content
Go to top

Satellite Assembly and Implementation Details

, 27 Sep 2007
Rate this:
Please Sign up or sign in to vote.
Through this article, we will explain the use and implementation details of satellite assembly.

Introduction

Microsoft released the .NET Framework and common language runtime model, targeting high productivity in software development. Their goal was to create an enriched user experience with easy-to-use products. Satellite assembly comes into the picture when we develop an application that is localized to a specific culture. Throughout this article, we will explain the use and implementation details of satellite assembly.

However, in order to talk about localization, we must know about resource files. Resource files are nothing but a key and textual value collections specific to each language. Therefore we will have to create a resource file for each language that we plan to support. The .NET Framework classes will retrieve language-specific details from these multiple language resource files based on the chosen language context.

Resource File and Satellite Assembly

As we discussed earlier, resource files are essentially a collection of associations between key and textual values specific to a particular language. Resource files can be text, XML or binary resource files. Presumably, the resource file can be generated by language translators in either of the discussed file types. This can later converted using resgen.exe, which can convert a resource file from one format to another. Later, this file gets compiled and will become part of your application. This is called satellite assembly.

To create a resource file, you can highlight a project or a folder and add a new item of the type "assembly resource." This will create a resource file with the extension *.resx. It is also clear that you can have multiple resource files in your project. Once we fill the *.resx file with language-specific details, we then need to use resgen.exe to create a resource file. The below statement will help to achieve this same idea.

resgen fr-FR.resx SatelliteAssembly.fr-FR.resources
Screenshot - image001.jpg
  • resgen: this is the executable to create a resource file from text, XML or binary resource.
  • fr-FR.resx: this contains such language-specific information as Key/Value collection.
  • SatelliteAssembly.fr-FR.resources: the output file name of generated resource file.

The next step is to create a satellite assembly from the resource generated by the last command line execution. To create a satellite assembly, we can use an assembly linker, al.exe (see MSDN article), which is shipped along with the Visual Studio software kit.

al /t:lib /embed:SatelliteAssembly.fr-FR.resources
/culture:fr /out:SatelliteAssembly.fr-FR.resources.dll
Screenshot - image002.jpg
  • t:lib: this specifies the file format of the output file.
  • /embed: this embeds the resource specified by the file in the image that contains the assembly manifest; Al.exe copies the contents of the file into the portable executable (PE) image.
  • /culture: this specifies the culture string to associate with the assembly.
  • /out: this is the name of the satellite assembly.

Repeat the above two command line expressions to create the satellite assembly for all required language support. So, at this stage we are done with the core part of localization. The next phase would be binding the language-specific details to the control object (in this example).

Resource Manager

The ResourceManager class looks up culture-specific resources, provides resource fallback when a localized resource does not exist, and supports resource serialization.

The enclosed example will be using the GetString method of ResourceManager, which can read the textual information from the resources for a particular culture. By default, this method returns the resource for the culture determined by the current cultural settings of the thread that made the call.

In the source code, we have a Windows Form object with combo box control. This combo box will populate all the available cultures.

Screenshot - image003.jpg
ResourceManager rm = null;
CultureInfo ci = Thread.CurrentThread.CurrentCulture;
if (comboBox1.Text == "German - Germany")
{
    rm = new ResourceManager("SatelliteAssembly.de-DE", 
        Assembly.GetExecutingAssembly());
    lblOne.Text = rm.GetString("StrMsgOne");
    lblTwo.Text = rm.GetString("StrMsgTwo");
}
Screenshot - image004.jpg
else if (comboBox1.Text == "French - France")
{
    rm = new ResourceManager("SatelliteAssembly.fr-FR", 
        Assembly.GetExecutingAssembly());
    lblOne.Text = rm.GetString("StrMsgOne");
    lblTwo.Text = rm.GetString("StrMsgTwo");
}
Screenshot - image005.jpg

Note: The code block enclosed here is just to demonstrate the GetString method of the ResourceManager class. You can download the source code and then fine-tune the logic or you can use the example.

History

  • 27 September, 2007 -- Original version posted
  • 28 September, 2007 -- Article content updated

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

sreejith ss nair
Software Developer (Senior) Freelance
India India
He is a certified professional in both MCPD and MCTS. He is a mathematics graduate with masters in computer science.He was born and bred in India and happen to spend some time in Europe.

Comments and Discussions

 
GeneralDoubled article PinmemberPrzemyslaw Celej29-Sep-07 12:12 
GeneralRe: Doubled article Pinmembersreejith ss nair30-Sep-07 20:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 27 Sep 2007
Article Copyright 2007 by sreejith ss nair
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid