|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Locating and Using Resources for a Specific Culture
The common language runtime provides support for retrieving culture-specific resources that are packaged and deployed in satellite assemblies. Satellite assemblies only contain resource files, or loose resources such as .gif files. They do not contain any executable code.
In the satellite assembly deployment model, you create an application with a default assembly (the main assembly) and several satellite assemblies. You should package the resources for the default or neutral assembly with the main assembly and create a separate satellite assembly for each language that your application supports. Because the satellite assemblies are not part of the main assembly, you can easily replace or update resources corresponding to a specific culture without replacing the application's main assembly.
The ResourceManager class provides access to culture-specific resources at run time and controls how the application retrieves resources by using the resource fallback process. For more information, see the "Resource Fallback Process" subtopic in the topic. The ResourceManager determines which resources to retrieve based upon the current thread's CultureInfo.CurrentUICulture property. For example, if an application is compiled with default English language resources in the main assembly and two satellite assemblies containing resources for French and German language resources, and the CurrentUICulture property is set to "de", the ResourceManager retrieves the German resources.
The CurrentUICulture property can be set in several ways. Be aware that the way this property is set will affect how the ResourceManager retrieves resources based on culture:
The CurrentUICulture property can be set to a specific culture in the application's code, such as "fr-CA" for French in Canada. When you explicitly set CurrentUICulture in code, you guarantee that the resources for that culture will always be retrieved regardless of the user's browser or system language. Consider an application that is compiled with default English language resources and two satellite assemblies containing resources for French and German language resources. If the CurrentUICulture property is set to "de" in the application's code, the ResourceManager will always retrieve the German resources, even if the user's system language is set to French. Make sure that this is the desired behavior before setting this property explicitly in code.
In ASP.NET applications, it is necessary to set the CurrentUICulture explicitly because it is unlikely that the setting on the server will match the incoming client requests.
The CurrentUICulture property will be set implicitly if an application does specify a CurrentUICulture. If CurrentUICulture is not set explicitly in an application's code, it is set by the GetUserDefaultUILanguage function on Windows 2000 and Windows XP Multilingual User Interface (MUI) products where the end user can set the default language. If the user's UI language is not set, it will be set by the system-installed language, which is the language of the operating system's resources.
If an application is Web-based, the CurrentUICulture can be set explicitly in application code to the user's browser accept language.
For examples of setting the CurrentUICulture property, see Using the CurrentUICulture Property.