Packaging Application Resources


Nearly every production-quality application needs to use resources. A resource is any nonexecutable data that is logically deployed with an application. A resource might be displayed in an application as error messages or as part of the user interface. Resources can contain data in a number of forms, including strings, images, and persisted objects. Storing your data in a resource file allows you to change the data without recompiling your entire application. Note that in order to write persisted objects to a resource file, the objects must be serializable.

The .NET Framework supports the creation and localization of application resources as well as a model for packaging and deploying localized resources. Application resources are localized for specific cultures to build translated versions of applications. An application loads the appropriate localized resources based on the value of the CultureInfo.CurrentUICulture property. This value is set either in the application code or by the common language runtime for the current user on the local computer.

You can deploy application resources in satellite assemblies because satellite assemblies only contain resource files and not any application code. In the satellite assembly deployment model, an application is created with one default assembly, the main assembly, and several satellite assemblies. One satellite assembly should be created for each culture that the application supports. Because the satellite assemblies are not part of the main assembly, certain resources can easily be replaced or updated without replacing the application's main assembly.

To localize a Windows form, set the Localizable form property to true and save the project. A language translator can use the Windows Resource Localization Editor application to load the form and create the localized version by changing the text and control sizes. Figure 8-15 illustrates using the resource editor while the View Issue page is translated into German. Having a translator change the control text makes perfect sense. However, allowing a translator to be able to change the control's dimensions or locations is also important because the translated labels may require larger control dimensions. The editor does not permit a translator to access or modify the functional source code bound to the form.

click to expand
Figure 8-15: Editing a form resource in the Windows Resource Localization Editor
Note  

You can launch the Windows Resource Localization Editor from C:\Program Files\Microsoft Visual Studio .NET 2003\ SDK\v1.1\Bin\WinRes.exe.

After the translator edits the resource, you can save the form with an associated culture code ”in this case, de-DE, for Germany. The resource is deployed along with the rest of the application. Upon execution, the application checks the local culture settings. If they are set to de-DE, as would be expected in Germany, then the application displays the localized form. If a culture is specified that is not localized, then the default form is displayed ”in this case, English.




Developing. NET Enterprise Applications
Developing .NET Enterprise Applications
ISBN: 1590590465
EAN: 2147483647
Year: 2005
Pages: 119

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net